Ch 9 Quiz Questions

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

The ____________ and ____________ operators can be used to increment or decrement a pointer variable.

++,--

What will the following code output? int number = 22; int **var = &number; cout << **var << endl;

22

When this is placed in front of a variable name, it returns the address of that variable.

Ampersand ( & )

True/False: The ampersand ( & ) is used to deference a pointer variable in C++.

False

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

False

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

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

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

This statement assigns the dereferenced pointer's value, then increments the pointer's address.

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

True

True/False: An array name is a pointer constant because the address stored in it cannot be changed during runtime.

True

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;

True

A pointer variable may be initialized with

a valid address in the computer's memory

Every byte in the computer's memory is assigned a unique ____________.

address

The following statement int *ptr = new int;

assigns an address to the variable named ptr

Which statement displays the address of the variable num1?

cout << &num1;

Which of the following statements deletes memory that has been dynamically allocated for an array?

delete [ ] array;

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

indirectly

The statement: int *ptr = nullptr; has the same meaning as ____________.

int* ptr = nullptr;

Not all arithmetic operations may be performed on pointers. For example, you cannot ____________ or ____________ a pointer.

multiply or divide

When you pass a pointer as an argument to a function, you must ____________. a) deference the pointer variable b) declare the pointer variable again in the function call c) use the #include <func_ptr.h> statement d) not dereference the pointer in the function's body

none of these

In C++ 11, the ________ key word was introduced to represent the address 0.

nullptr

Look at the following statement: int *ptr = nullptr; In this statement, what does int mean?

ptr is a pointer variable that will store the address of an integer variable

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 is true?

ptr will hold the address of numbers[1]

When you work with a dereferenced pointer, you are actually working with ____________.

the actual value of the variable whose address is stored in the pointer variable

If a variable uses more than one byte of memory, for pointer purposes its address is ____________.

the address of the first byte of storage

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


संबंधित स्टडी सेट्स

Renaissance and Protestant Reformation Test

View Set

Eviro. Unit 8 lesson 5: Climate Change

View Set

Retirement Other Insurance Concepts

View Set

Chapter 5 - Small business, entrepreneurship, and franchises

View Set

unit 2 - research chapter - answers to first test

View Set