WorksheetsFunction session 7
Total questions: 10
Worksheet time: 9mins
What is a function?
A type of variable
A block of code that does a specific task
A loop
A data type
Which keyword means a function returns nothing?
int
void
return
null
int add(int a, int b) {
return a + b;
}
int main() {
cout << add(5, 3);
}
5
8
3
2
What does sqrt(16) return?
2
4
16
64
How do you call a function named greet?
call greet();
greet();
run greet();
function greet();
void sayHello() {
cout << "Hello!";
}
int main() {
sayHello();
}
Nothing
Hello
Error
sayHello()
What is Recursion?
A loop that runs forever
A function that calls itself
A function with multiple parameters
Using the same variable name twice
What does pow(2, 3) return?
5
8
6
9
What is function overloading?
Calling a function multiple times
Using the same function name with different parameters
A function that calls itself
A function with no return type
int multiply(int a, int b = 5) {
return a * b;
}
int main() {
cout << multiply(3);
}
0
15
3
compiler error
