CIS C++ Chapter 10 Quiz

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

ampersand ( & )

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;

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

___ can be used as pointers.

Array names

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

nullptr

What does the following statement do?

double *num2;

Declares a pointer variable named num2.

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

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

A function may return a pointer, but the programmer must ensure that the pointer ___.

still points to a valid object after the function ends

Which of the following statements is not valid C++ code?

All of these are invalid. ( int ptr = &num1; int ptr = int *num1; float num1 = &ptr2; )

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

delete [] array;

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

ampersand ( & )

What will the following statement output?

cout << &num1;

The memory address of the variable called num1

A pointer variable is designed to store ___.

a memory address

Look at the following statement:

int *ptr = nullptr;

In this statement, what does the word int mean?

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

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.

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

multiply, divide

Which statement displays the address of the variable num1?

cout << &num1;

The following statement:

cin &gt;&gt; *num3;

stores the keyboard input into the variable pointed to by num3

Dynamic memory allocation occurs ___.

when a new variable is created at runtime

The following statement:

int *ptr = new int;

assigns an address to the variable named ptr

If you are using an older compiler that does not support the C++ 11 standard, you should initialize pointers with ___.

the integer 0, or the value NULL

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

address

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

the address of the first byte of storage

What will the following code output?

int number = 22;

int *var = &amp;number;

cout &lt;&lt; *var &lt;&lt; endl;

22

What will the following code output?

int *numbers = new int;

for (int i = 0; i &lt;= 4; i++)

*(numbers + i) = i;

cout &lt;&lt; numbers &lt;&lt; endl;

2

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.

CIS C++ Chapter 10 Quiz - Subjecto.com

CIS C++ Chapter 10 Quiz

Your page rank:

Total word count: 572
Pages: 2

Calculate the Price

- -
275 words
Looking for Expert Opinion?
Let us have a look at your work and suggest how to improve it!
Get a Consultant

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

ampersand ( & )

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;

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

___ can be used as pointers.

Array names

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

nullptr

What does the following statement do?

double *num2;

Declares a pointer variable named num2.

When the less than ( &lt; ) 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

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

A function may return a pointer, but the programmer must ensure that the pointer ___.

still points to a valid object after the function ends

Which of the following statements is not valid C++ code?

All of these are invalid. ( int ptr = &num1; int ptr = int *num1; float num1 = &ptr2; )

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

delete [] array;

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

ampersand ( & )

What will the following statement output?

cout &lt;&lt; &amp;num1;

The memory address of the variable called num1

A pointer variable is designed to store ___.

a memory address

Look at the following statement:

int *ptr = nullptr;

In this statement, what does the word int mean?

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

Assuming ptr is a pointer variable, what will the following statement output?

cout &lt;&lt; *ptr;

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

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

multiply, divide

Which statement displays the address of the variable num1?

cout << &num1;

The following statement:

cin &gt;&gt; *num3;

stores the keyboard input into the variable pointed to by num3

Dynamic memory allocation occurs ___.

when a new variable is created at runtime

The following statement:

int *ptr = new int;

assigns an address to the variable named ptr

If you are using an older compiler that does not support the C++ 11 standard, you should initialize pointers with ___.

the integer 0, or the value NULL

Every byte in the computer’s memory is assigned a unique ___.

address

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

the address of the first byte of storage

What will the following code output?

int number = 22;

int *var = &amp;number;

cout &lt;&lt; *var &lt;&lt; endl;

22

What will the following code output?

int *numbers = new int[5];

for (int i = 0; i &lt;= 4; i++)

*(numbers + i) = i;

cout &lt;&lt; numbers[2] &lt;&lt; endl;

2

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].

Share This
Flashcard

More flashcards like this

NCLEX 10000 Integumentary Disorders

When assessing a client with partial-thickness burns over 60% of the body, which finding should the nurse report immediately? a) ...

Read more

NCLEX 300-NEURO

A client with amyotrophic lateral sclerosis (ALS) tells the nurse, "Sometimes I feel so frustrated. I can’t do anything without ...

Read more

NASM Flashcards

Which of the following is the process of getting oxygen from the environment to the tissues of the body? Diffusion ...

Read more

Unfinished tasks keep piling up?

Let us complete them for you. Quickly and professionally.

Check Price

Successful message
sending