C++ II Exam:



NAME: Number:

Instructor : section:

1. For each of the following, write C++ statement(s) that perform the specified task. Assume that unsigned integers are stored in two bytes and that the starting address of the array is at location 1002500 in memory.

a. Declare an array of type unsigned int called values with five elements, and initialize the elements to the even integers from 2 to 10.(1 pt)

b. Declare vPtr as a pointer to unsigned int. (1 pt)

c. Write a statement that assigns the starting address of array values to pointer variable vPtr. (1 pt)

d. Use a for loop to print the elements of array values using pointer/offset notation. (2 pts)

e. Use a while loop to print the elements of array values by moving the pointer vPtr over all elements of array values. (3 pts)

f. What is the output of the following statements. (2 pts)

VPtr = value[4];

VPtr -= 4;

cout ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download