Ch9

24 July 2022
4.7 (114 reviews)
30 test answers

Unlock all answers in this set

Unlock answers (26)
question
When the less than (<) operator is used between two pointer variables, the expression is testing whether
answer
the address of the first variable comes before the address of the second variable in the computer's memory
question
When using the new operator with an older compiler, it is good practice to
answer
test the pointer for the NULL address
question
Not all arithmetic operations may be performed on pointers. For example, you cannot __ or __ a pointer
answer
multiply or divide
question
The statement cin>> *num3
answer
stores the keyboard input into the variable pointed to by num3
question
When this is placed in front of a variable name, it returns the address of that variable
answer
& ampersand
question
A pointer may be initialized with
answer
the address of an existing object
question
The statement int *ptr= new int;
answer
assigns an address to the variable named ptr
question
When you work with a dereferenced pointer, you are actually working with:
answer
the actual value of the variable whose address is stored in the pointer variable
question
The __ and __ operators can be used to increment or decrement a pointer variable
answer
++,--
question
Look at the following statement: sum=*array++; This statement...
answer
assigns the dereferenced pointer's value, then increments the pointer's address
question
Which statement display the address of the variable num1?
answer
cout<<&num1
question
A pointer variable may be initialized with
answer
any address in the computer's memory
question
The following statement has the same meaning as __. int *ptr;
answer
int* ptr;
question
Assuming ptr is a pointer variable, what will the following statement output? cout<<*ptr
answer
the value stored in the variable whose address is contained in ptr
question
Which of the following statements is not valid C++ code?
answer
All of these are invalid (int ptr=&num1; int ptr=int *num1; float num1=*ptr2; )
question
Dynamic memory allocation occurs
answer
when a new variable is created at runtime
question
When you pass a pointer as an argument to a function, you must
answer
none of these (redeclare the pointer pointer variable in the function call, dereference the pointer variable in the function prototype, use the #include statement, not dereference the pointer in the function's body)
question
A function may return a pointer, but the programmer must ensure that the pointer
answer
still points to a valid object after the function ends
question
Look at the following statement. int *ptr; In this statement, what does the word int mean
answer
ptr is a pointer variable that will store the address of an integer variable
question
These can be used as pointers
answer
array names
question
If a variable uses more that one byte of memory, for pointer purposes its address is
answer
the address of the first byte of storage
question
What will the following statement output? cout<<&num1;
answer
The memory address of the variable called num1
question
Which of the following statements deletes memory that has been dynamically allocated for an array
answer
delete[] array;
question
Every byte in the computer's memory is assigned a unique
answer
address
question
The __, also known as the address operator, returns the memory address of a variable
answer
ampersand (&)
question
A pointer variable is designed to store
answer
a memory address
question
Use the delete operator only on pointers that were
answer
created with the new operator
question
With pointer variables, you can__ manipulate data stored in other variables
answer
indirectly
question
What does the following statement do? double *num2;
answer
declares a pointer variable named num2
question
The contents of pointer variables may be changed with mathematical statements that perform
answer
addition and subtraction