wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Function Inception

Total questions: 20

Worksheet time: 22mins

Name
Class
Date
1.

Which of these is not a type for a function declaration?

a)

void

b)

string

c)

char

d)

number

2.

A function can have _____ inside the parenthesis

a)

loops

b)

Arguments/Parameters

c)

Braces

d)

Types

3.

True or False. A function has to be stated before main and described with the same exact declaration format like type name(aruments)

a)

True

b)

False

4.

function is executed when it is

a)

defined

b)

prototyped

c)

declared

d)

called

5.

A function __________ contains the statements that make up the function.

a)

prototype

b)

definition

c)

call

d)

expression

6.

Which of the following is a complete and correct function definition?

a)

int funct();

b)

int funct(int x){ x = x +1; return x; }

c)

void funct(int){ cout<< “Hello”;

d)

void funct(x){ cout<< “Hello”; return 0; }

7.

What is the return type of the function with prototype: "int func(char x, float v, double t);"?

a)

char

b)

int

c)

float

d)

double

8.

What is the return type of the function with prototype: "string func(int x, char t);"?

a)

string

b)

int

c)

float

d)

double

9.

What will the above code display?

a)

2

2

b)

4

2

c)

2

4

d)

4

4

10.

True or False: A function may or may not return a value back to the caller.

a)

True

b)

False

11.

Fill in the blank to have this function work properly


int function ( ___ x, ____ w) {


cout<<"Let's sum it up";


return x + w;


}

a)

string

b)

int

c)

void

d)

variable

12.

Fill in the blank to have this function work properly


_____ function (int x, int y ) {


for(int i = 0; i < x; i ++){

if(x == y){

cout<<"Found it";

return 0;

}


}

a)

string

b)

int

c)

void

d)

variable

13.

Fill in the blank to have this function work properly


_____ function ( ) {


string hello = "Welcome to my game";


return hello;


}

a)

char

b)

void

c)

string

d)

variable

14.

Fill in the blank to have this function work properly


_____ function ( ) {


double a;

cin >> a;


return a;


}

a)

string

b)

double

c)

int

d)

variable

15.

Fill in the blank to have this function work properly


_____ function ( ) {


int a = 4;

int b = 5;


cout<<"This multiplied quickly " << a*b;


}

a)

string

b)

int

c)

void

d)

variable

16.

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

17.

A function that is void cannot have a _____ _______

a)

variable calculation

b)

printing statement

c)

Return statement

d)

cout statement

18.

What is the return type of the function with prototype: "double func(string x, int s, double t);"?

a)

char

b)

int

c)

string

d)

double

19.

Which of these lines shows the correct code to invoke the function showDub?

a)

int showDub(int x);

b)

showDub(10);

c)

showDub;

d)

showDub(10, 10);

20.

Fill in the blank to have this function work properly


_____ func (int x, int y ) {


for(int i = x; i < x; i ++){

if(x == y){

cout<<"Found it";


}


}

a)

char

b)

void

c)

string

d)

variable