Programming Fundamentals 3

25 July 2022
4.7 (114 reviews)
25 test answers

Unlock all answers in this set

Unlock answers (21)
question
A function may return a pointer, but the programmer must ensure that the pointer ________.
answer
is pointing to an object that is still valid after the return of the function
question
A pointer may be initialized with ________.
answer
the address of an existing object of the appropriate type
question
Assuming that arr is an array identifier, the statement sum += *arr; ________.
answer
adds the value stored in arr[0] to sum
question
If arr is an array identifier and k is an integer, the expression arr[k] is equivalent to
answer
*(arr + k)
question
The ________, also known as the address operator, returns the memory address of a variable.
answer
ampersand ( & )
question
The code segment int *ptr; has the same meaning as ________.
answer
int* ptr;
question
The statement double *num; ________.
answer
defines a pointer variable called num
question
The term pointer can be used interchangeably with ________.
answer
address
question
The delete operator should only be used on pointers that ________.
answer
point to storage allocated by the new operator
question
To dereference a structure pointer and simultaneously access a member of the structure, the appropriate operator to use is ________.
answer
the structure pointer operator, ->
question
True/False: A pointer with the value 0 (zero) is called the NULL pointer.
answer
True
question
True/False: An array name is a pointer constant because the address it represents cannot be changed during run-time.
answer
True
question
True/False: It is legal to subtract a pointer variable from another pointer variable.
answer
True
question
True/False: The expression s->m has the same meaning as (*s).m.
answer
True
question
True/False: The expression s->m is meaningful only when s is a pointer to a structure and m is a member of the structure.
answer
True
question
True/False: Variables cannot be created when a program is already running.
answer
False
question
True/False: With pointer variables you can access, but you cannot modify, data in other variables.
answer
False
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 you work with a dereferenced pointer, you are actually working with ________.
answer
the variable whose address is stored in the pointer variable
question
Which arithmetic operations can be performed on pointers?
answer
Addition , subtraction , preincrement, and postincrement
question
Which of the following statements correctly deletes a dynamically-allocated array pointed to by p?
answer
delete [ ] p;
question
Which of the following statements correctly deletes a dynamically-allocated array pointed to by p?
answer
int ptr = int *num1; int ptr = &num1; float num1 = &ptr2; All of the above are invalid
question
With pointer variables, you can ________ manipulate data stored in other variables.
answer
indirectly
question
You may use a pointer to a structure as a ________.
answer
function parameter function return type structure member
question
________ can be used as pointers.
answer
Array names