Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C++ Functions

Total questions: 11

Worksheet time: 11mins

Name
Class
Date
1.

A function can have _____ inside the parenthesis

a)

loops

b)

Arguments/Parameters

c)

Braces

d)

Types

2.

A function that has no return type starts with:

a)

int

b)

void

c)

Arguments

d)

Braces

3.

A function that returns a whole number starts with the word

a)

int

b)

void

c)

string

d)

{ }

4.

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

5.

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

6.

Fill in the blank to have this function work properly


_____ function ( ) {


int a;

cin >> a;


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


}

a)

string

b)

void

c)

int

d)

variable

7.

True or False. We can call functions inside of other functions.

a)

True

b)

False

8.

True or False. A function that returns a string starts with the word void.

a)

True

b)

False

9.

Select all of the types you may have for a function

a)

string

b)

bool

c)

void

d)

variable

e)

int

10.

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

a)

variable calculation

b)

printing statement

c)

Return statement

d)

cout statement

11.

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