Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Function session 7

Total questions: 10

Worksheet time: 9mins

Name
Class
Date
1.

What is a function?

a)

A type of variable

b)

A block of code that does a specific task

c)

A loop

d)

A data type

2.

Which keyword means a function returns nothing?

a)

int

b)

void

c)

return

d)

null

3.

int add(int a, int b) {

return a + b;

}

int main() {

cout << add(5, 3);

}

a)

5

b)

8

c)

3

d)

2

4.

What does sqrt(16) return?

a)

2

b)

4

c)

16

d)

64

5.

How do you call a function named greet?

a)

call greet();

b)

greet();

c)

run greet();

d)

function greet();

6.

void sayHello() {

cout << "Hello!";

}

int main() {

sayHello();

}

a)

Nothing

b)

Hello

c)

Error

d)

sayHello()

7.

What is Recursion?

a)

A loop that runs forever

b)

A function that calls itself

c)

A function with multiple parameters

d)

Using the same variable name twice

8.

What does pow(2, 3) return?

a)

5

b)

8

c)

6

d)

9

9.

What is function overloading?

a)

Calling a function multiple times

b)

Using the same function name with different parameters

c)

A function that calls itself

d)

A function with no return type

10.

int multiply(int a, int b = 5) {

return a * b;

}

int main() {

cout << multiply(3);

}

a)

0

b)

15

c)

3

d)

compiler error