Recall & Review
beginner
What is a function call in C++?
A function call is when you ask a function to run its code by using its name followed by parentheses, optionally with arguments inside.
Click to reveal answer
beginner
How do you pass information to a function when calling it?
You pass information by putting values called arguments inside the parentheses of the function call.
Click to reveal answer
beginner
What happens if a function returns a value?
When a function returns a value, the function call can be used in expressions or assigned to variables to use that returned value.
Click to reveal answer
beginner
Example: What does this code do?<br>
int add(int a, int b) { return a + b; }<br>int result = add(3, 4);It calls the function 'add' with 3 and 4 as arguments. The function adds them and returns 7, which is stored in 'result'.
Click to reveal answer
intermediate
Can a function call be inside another function call?
Yes! This is called nesting. For example, you can call a function inside the arguments of another function call.
Click to reveal answer
What is the correct way to call a function named 'printMessage' with no arguments?
✗ Incorrect
In C++, to call a function you use its name followed by parentheses. If there are no arguments, the parentheses are empty.
If a function 'sum' takes two integers, how do you call it with 5 and 10?
✗ Incorrect
Function arguments are passed inside parentheses separated by commas.
What does this function call return?<br>
int square(int x) { return x * x; }<br>square(3);✗ Incorrect
The function multiplies 3 by 3 and returns 9.
Which of these is a nested function call?
✗ Incorrect
Calling 'sum' inside the arguments of 'print' is nesting function calls.
What happens if you forget the parentheses when calling a function?
✗ Incorrect
Without parentheses, you refer to the function, not call it.
Explain in your own words what happens when you call a function in C++.
Think about how you ask a friend to do something by name.
You got /5 concepts.
Describe how you can use the value returned by a function call.
Returned values are like results you can use immediately.
You got /4 concepts.