Engineering Problem Solving with C++, 3e Chapter 9 Test Bank
12. Using he following C++ statements which option correctly describes the result of the
statement a = *ptr;
int a(6), b(9), *ptr(&b);
a = *ptr;
A. The value of variable a is changed to the value of variable b.
B. The value of variable b is changed to the value of variable a.
C. The value of variable ptr is changed to point to the address of variable a.
D. The address of variable a is changed to the address of variable b.
13. Given the following declaration which of the statements given in the options is not a valid
C++ statement.
int x(5), y(7), *ptr1(&x), *ptr2(&y);
14. Using the statement double *ptr, x[6]={1.5, 2.2, 4.3, 7.5, 9.1, 10.5}; which of the following
statements is not a valid statement.
15. The address of an object is the same from one execution to the next execution.
16. A pointer is a variable which holds an address as its value.
17. When pointer variable ptr1 is declared to have base type double and initialized, the statement
ptr1++; changes the value of ptr1 by adding one to the address in ptr1.
18. Pointer references to array values are based on the knowledge that memory assignment of
array values is always sequential.
A. True B. False
19. An array variable can be passed to a pointer parameter.
A. True B. False
20. The declaration const char *c_ptr=”try this”; means that the value of c_ptr can not be
changed in other words c_ptr can not point to some other string.
A. True B. False
21. The declaration char const *cptr =”another phrase”; is an invalid statement because the
keyword const is in the wrong place.
A. True B. False
22. Dynamic memory is allocated from a region of the program’s memory called the heap.
A. True B. False
23. A memory leak occurs when you fail to delete dynamically allocated memory when it is not
longer needed.
A. True B. False