wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

array pointer

Total questions: 29

Worksheet time: 15mins

Name
Class
Date
1.

What does the following declaration mean?

int (*ptr)[10];

a)

ptr is array of pointers to 10 integers

b)

ptr is a pointer to an array of 10 integers

c)

ptr is an array of 10 integers

d)

ptr is an pointer to array

2.

An entire array is always passed by ___ to a called function.

a)

A) Call by value

b)

B) Call by reference

c)

C) Address relocation

d)

D) Address restructure

3.

a)

2, 3, 4, 5

b)

1, 2, 3, 4

c)

0, 1, 2, 3

d)

3, 2, 1 0

4.

a)

2,1,15

b)

1,2,5

c)

3,2,15

d)

2,3,20

5.

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

a)

asterisk (* )

b)

ampersand ( & )

c)

percent sign ( % )

d)

exclamation point ( ! )

6.

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

a)

still points to a valid object after the function ends

b)

has not been assigned an address

c)

was received as a parameter by the function

d)

has not previously been returned by another function

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.

A pointer variable is designed to store

a)

any legal C++ value

b)

only floating-point values

c)

an integer

d)

a memory address

11.

■An array is a group of memory locations that have ______________________________.

a)

the same name and different type

b)

the same name

c)

the same name and the same type.

d)

the different name and type

12.

A function can have _____ inside the parenthesis

a)

loops

b)

Arguments/Parameters

c)

Braces

d)

Types

13.

A function that has no return type starts with:

a)

int

b)

void

c)

Arguments

d)

Braces

14.

A function that returns a whole number starts with the word

a)

int

b)

void

c)

string

d)

{ }

15.

Fill in the blank to have this function work properly


_____ function ( ) {


int a = 4;

int b = 5;


cout<<a*b;


}

a)

string

b)

int

c)

void

d)

variable

16.

Fill in the blank to have this function work properly


_____ function ( ) {


string greeting = "Welcome to my game";


return greeting;


}

a)

string

b)

void

c)

int

d)

variable

17.

A function that is not void needs to have a _____ _______

a)

variable calculation

b)

printing statement

c)

Return statement

d)

cout statement

18.

Fill in the blank to have this function work properly


double function ( ) {


int a;

cin >> a;


cout<<"You chose " << a <<endl;


return ____ ;


}

a)

"a"

b)

a

c)

a * 3.14

d)

cin

19.

Voids

a)

A statement that returns a value

b)

A statement that doesn't return a value

c)

A function that return a value

d)

A function that doesn't return a value

20.

iostream

a)

Displays output from the screen and input from the keyboard

b)

Has all the math equations

c)

Counts the time

d)

Checks if the code has a function

21.

If-else

a)

Optional value for the program to execute

b)

Is a condition followed by a statement or a set of statements

c)

Is a statement followed by a condition or a set of conditions

d)

Function with a value

22.

Do while loops

a)

Runs a statement once

b)

Runs a statement twice

c)

Runs a statement multiple times or not within a boolean condition

d)

Doesn't run at all

23.

Switch Statement

a)

Is a statement with a set of conditions called cases

b)

Is a case

c)

Is a condition with no cases

d)

Is a boolean statement

24.

Which of the following is the default return value of functions in C++?

a)

int

b)

char

c)

float

d)

void

25.

What is an inline function?

a)

A function that is expanded at each call during execution

b)

A function that is called during compile time

c)

A function that is not checked for syntax errors

d)

A function that is not checked for semantic analysis

26.

When we define the default values for a function?

a)

When a function is defined

b)

When a function is declared

c)

When the scope of the function is over

d)

When a function is called

27.

it is the statement that indicates a function will be used.

a)

function declaration

b)

function definition

c)

function call

d)

function name

28.

What will be the output of the following C++ code?

a)

10

b)

0

c)

Syntax error

d)

Segmentation fault

29.

It is a return type that means no value is returned.

a)

void

b)

int

c)

double

d)

char