Preview only show first 10 pages with watermark. For full document please download

C++ Test Bank

Section 11.2 Pointer Basics 1 Which of the following correctly declares pointer variables. A. int *x; B. int x; C. int &x; D. int **x; The correct answer is A Your answer B is incorrect 2 Suppose you declare int count = 5; which of the following is true? A. &count is the address of count B. &count is 5 C. *count is the address of count D. *count is 5 The correct answer is A Your answer B is incorrect 3 Suppose you declare int count = 5 and int *pCount = &count; which of the following is true? A.

   EMBED


Share

Transcript

  Section 11.2 Pointer Basics 1 Which of the following correctly declares pointer variables.A. int *x;B. int x;C. int &x;D. int **x;The correct answer is AYour answer B is incorrect 2 Suppose you declare int count = 5; which of the following is true?A. &count is the address of countB. &count is 5C. *count is the address of countD. *count is 5The correct answer is AYour answer B is incorrect 3 Suppose you declare int count = 5 and int *pCount = &count; which of the following is true?A. *count is the address of countB. &count is 5C. *pCount is 5D. pCount contains the address of countThe correct answer is CDYour answer A is incorrect 4 The ampersand (&) used in the following statement is known as ___________. int count = 5;cout << &count;A. indirection operator B. dereference operator C. multiply operator   D. address operator The correct answer is DYour answer is correct 5 If you declare a variable double d = 5.5 and compiler stores it in the memory starting withaddress 04BFA810, then &d is _______________.A. 5B. 5.5C. 0D. unknownE. 04BFA810The correct answer is EYour answer A is incorrect 6  The asterisk (*) used in the following statement is known as ___________.cout << *pCount;A. indirection operator B. dereference operator C. multiply operator D. address operator The correct answer is ABYour answer D is incorrect 7  Why the following pointer variable declaration is wrong?int area = 1;double *pArea = &area;A. double *pArea = &area should be double *pArea = area;B. the type of variable does not match the type of the pointer.C. double *pArea = &area should be float *pArea = area;D. double *pArea = &area should be int *pArea = area;  The correct answer is BDYour answer A is incorrect 8 Which of the following statements are true?A. A local variable is assigned an arbitrary value if you don?t initialize it.B. A local pointer is assigned an arbitrary value if you don?t initialize it.C. An array element is assigned an arbitrary value if you don?t initialize it.D. Dereferencing a pointer that is not initialized could cause fatal runtime error or it couldaccidentally modify important data.The correct answer is ABCDYour answer A is incorrectSection 11.3 Using const with Pointers 9 Suppose you declare the following:double radius = 5;double * const pValue = &radius;Which of the following statements are allowed?A. radius++;B. (*pValue)++;C. pValue = &radius;D. *pValue = 0;The correct answer is ABDYour answer A is incorrect 10 Suppose you declare the following:double radius = 5;const double * pValue = &radius;Which of the following statements are allowed?A. radius++;B. (*pValue)++;  C. pValue = &radius;D. *pValue = 0;The correct answer is CYour answer D is incorrect 11 Suppose you declare the following:double radius = 5;const double const* pValue = &radius;Which of the following statements are allowed?A. radius++;B. (*pValue)++;C. pValue = &radius;D. *pValue = 0;E. cout << *pValue;The correct answer is EYour answer A is incorrectSection 11.4 Arrays and Pointers 12 Suppose int list[6] = {11, 12, 13, 14, 15, 16}; Is *list the same as list[0]?A. yesB. noThe correct answer is AYour answer B is incorrect 13 If you declare an array double list[] = {1, 3.4, 5.5, 3.5} and compiler stores it in the memorystarting with address 04BFA810, which of the following displays 04BFA810?A. cout << list << endl;B. cout << &list << endl;C. cout << list[0] << endl;D. cout << &list[0] << endl;