Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. True/false Assuming myValues is an array of int values, and index is an int v

ID: 3570742 • Letter: 1

Question

1. True/false

Assuming myValues is an array of int values, and index is an int variable, both of the following statements do the same thing.

cout << myValues [index] <<endl;

cout << * (myValues + index) << endl;

a)true

b)false

2.What will the following code output?

int number = 22;

int *var = &number;

cout << var << endl;

a)the adress of the number variable

b)22

c)an asterisk followed by 22

d)an asterisk followed by the address of the number variable

3. what will the following code output?

int *numbers = new int[5];

for (int i = 0; i <= 4; i++)

*(numbers + i) = i;

cout << numbers [2] << endl;

a)five memory addresses

b)0

c)3

d)2

e)1

4. Look at the following code:

int numbers [] = {0, 1, 2, 3, 4};

int *ptr = numbers;

ptr++;

After this code executes, which of the following statements in true?

a) ptr will hold the address of numbers [0]

b)ptr will hold the address of the 2nd byte within the element numbers [0]

c)ptr will hod the address of numbers [1]

d)this code will not compile

5. The following statement:

cin >> *num3;

a) stores the keyboard input into the variable num3

b) stores the keyboard input into the pointer called num3

c)is illegal in C++

d)stores the keyboard input into the variable pointed to by num3

e)none of these

6. The following statement:

int *ptr = new int;

a) results in a compile error

b) assigns an integer less than 32767 to variable named ptr

c) assigns an address to the variable named ptr

d) creates a new pointed named int

e) none of these

Explanation / Answer

1) a)True

2   a)the adress of the number variable

3 d)2

4 c)ptr will hod the address of numbers [1]

5 d)stores the keyboard input into the variable pointed to by num3

6 d) creates a new pointed named int