Filters
Question type

Study Flashcards

Which arithmetic operations can be performed on pointers?


A) Multiplication, division, addition, and subtraction
B) Addition , subtraction , preincrement, and postincrement
C) Only multiplication and addition
D) All arithmetic operations that are legal in C++
E) None of the above

Correct Answer

verifed

verified

The statement cout << &num1; will output


A) the memory address of the variable called num1.
B) the value stored in the variable called num1.
C) the number 1.
D) the string "&num1".
E) None of the above

Correct Answer

verifed

verified

The statement int *ptr = new int; acquires memory to hold an integer and then


A) creates a new pointer called int.
B) sets ptr to point to the allocated memory.
C) initializes the allocated memory to 0.
D) assigns an integer value to the variable called ptr.
E) None of the above

Correct Answer

verifed

verified

When you work with a dereferenced pointer, you are actually working with


A) a copy of the value pointed to by the pointer variable.
B) a variable whose memory has been deallocated.
C) the variable whose address is stored in the pointer variable.
D) All of the above
E) None of the above

Correct Answer

verifed

verified

C++ does not perform array bounds checking.

Correct Answer

verifed

verified

The code segment int *ptr; has the same meaning as


A) int* ptr;.
B) int ptr*;.
C) *int ptr;.
D) int ptr;.
E) None of the above

Correct Answer

verifed

verified

can be used as pointers.


A) C++ string objects
B) Punctuation marks
C) Array names
D) All of the above
E) None of the above

Correct Answer

verifed

verified

Any time you use the new operator, it is good practice to


A) clear the data from the old operator
B) use a preprocessor directive.
C) use delete afterwards to free the memory allocated by new.
D) All of the above
E) None of the above

Correct Answer

verifed

verified

If s is a structure variable and p, a pointer, is a member of the structure, the statement cout << *s.p; will


A) output the value stored in s.
B) output the dereferenced value pointed to by p.
C) output the address stored in p.
D) result in a compiler error.
E) None of the above

Correct Answer

verifed

verified

The statement cin >> *p;


A) stores the keyboard input into the variable pointed to by p.
B) is illegal in C++.
C) stores the keyboard input into the pointer called p.
D) stores the keyboard input into the variable p.
E) None of the above

Correct Answer

verifed

verified

A pointer variable may be initialized with


A) the address of an existing variable of the appropriate type.
B) any non- zero integer value.
C) A and B are both true.
D) None of the above

Correct Answer

verifed

verified

Which of the following statements correctly deletes a dynamically- allocated array pointed to by p?


A) delete [ ] p;
B) delete array p;
C) delete p;
D) p delete[ ];
E) None of the above

Correct Answer

verifed

verified

The statement cout << *ptr; will output


A) the address of the variable stored in ptr.
B) the string "*ptr".
C) the value stored in the variable whose address is contained in ptr.
D) the address of the variable whose address is stored in ptr.
E) None of the above

Correct Answer

verifed

verified

Assuming that arris an array identifier, the statement sum += *arr;


A) will always result in a compiler error.
B) is illegal in C++.
C) adds the address of the pointer arr to sum.
D) adds the value stored in arr[0] to sum.
E) None of the above

Correct Answer

verifed

verified

A pointer variable is designed to store


A) a memory address.
B) an integer.
C) any legal C++ value.
D) only floating- point values.
E) None of the above

Correct Answer

verifed

verified

The ampersand (&)is used to dereference a pointer variable in C++.

Correct Answer

verifed

verified

The statement double *num;


A) defines a pointer variable called num.
B) defines a variable of type double called num.
C) initializes a variable called *num.
D) defines and initializes a pointer variable called num.
E) None of the above

Correct Answer

verifed

verified

Which of the following statements is not valid C++ code?


A) float num1 = &ptr2;
B) int ptr = &num1;
C) int ptr = int *num1;
D) All of the above are valid.
E) All of the above are invalid.

Correct Answer

verifed

verified

With pointer variables, you can manipulate data stored in other variables.


A) seldom
B) never
C) indirectly
D) All of the above
E) None of the above

Correct Answer

verifed

verified

An array name is a pointer constant because the address it represents cannot be changed during run- time.

Correct Answer

verifed

verified

Showing 21 - 40 of 50

Related Exams

Show Answer