wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Reference and Pointers in C++

Total questions: 10

Worksheet time: 30mins

Name
Class
Date
1.

What does this symbol allow for in C++? -> *

a)

De-refrencing

b)

Summing numbers

c)

Making text more sparkly

d)

Performing modular operations

2.

What is the operator used for dereferencing or indirection?

a)

*

b)

&

c)

%

d)

&&

3.

Specify whether the statement below is valid or invalid.


int i;

double * dp = &i;

a)

Valid

b)

Invalid

4.

A pointer variable store a/an

a)

value of another value.

b)

value of another variable.

c)

address of another pointer.

d)

address of another variable.

5.

Given the following declarations:


int i;

int *pi;

double d;

double *pd;


Specify whether the statements below is valid or invalid.


pi = &i;

a)

Valid

b)

Invalid

6.

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

a)

asterisk (* )

b)

ampersand ( & )

c)

percent sign ( % )

d)

exclamation point ( ! )

7.

What does the following statement do?

double *num2;

a)

Declares a double variable named num2

b)

Declares and initializes a pointer variable named num2

c)

Initializes a pointer variable named num2

d)

Declares a pointer variable named num2

8.

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

cout << *ptr;

a)

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

b)

the string "*ptr"

c)

the address of the variable whose address is stored in ptr

d)

the address of the variable stored in ptr

9.

Which of the following statements displays the address of the variable numb?

a)

cout << numb;

b)

cout << *numb;

c)

cin >> &numb;

d)

cout << &numb;

10.

Which of the following statements displays the address of the variable var?

a)

cout << &var;

b)

cout << *var;

c)

cin >> var;

d)

cout << var&;