Quiz 8

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What will the following statement output? cout << &num1;

The memory address of the variable called num1.

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;

2

With pointer variables, you can __________ manipulate data stored in other variables.

indirectly

These can be used as pointers.

Array names

What does the following statement do? double *num2;

Declares a pointer variable named num2.

Look at the following code. int numbers[] = {0, 1, 2, 3, 4 }; int *ptr = numbers; ptr++; cout << *ptr << endl; After this code executes, what is the output?

Exact Match

True/False: With pointer variables you can access, but you cannot modify, data in other variables.

False

True/False: A pointer can be used as a function argument, giving the function access to the original argument.

True

The _________ , also known as the address operator, returns the memory address of a variable.

ampersand ( & )

Look at the following statement: sum += *array++; This statement...

assigns the dereferenced pointer's value, then increments the pointer's address

Use the delete operator only on pointers that were

created with the new operator

When the less than ( < ) operator is used between two pointer variables, the expression is testing whether

the address of the first variable comes before the address of the second variable in the computer's memory

Assuming ptr is a pointer variable, what will the following statement output? cout << *ptr << endl;

the value stored in the variable whose address is contained in ptr.


Kaugnay na mga set ng pag-aaral

19- Michigan Laws and Rules Pertinent to Insurance

View Set