0
0
C++programming~5 mins

Function calling in C++ - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Acall printMessage();
BprintMessage;
CprintMessage();
DprintMessage[];
If a function 'sum' takes two integers, how do you call it with 5 and 10?
Asum{5, 10};
Bsum[5, 10];
Csum 5, 10;
Dsum(5, 10);
What does this function call return?<br>
int square(int x) { return x * x; }<br>square(3);
A9
B6
C3
D0
Which of these is a nested function call?
Asum(2, 3);
Bprint(sum(2, 3));
Cprint(); sum(2, 3);
Dsum(2, 3); print();
What happens if you forget the parentheses when calling a function?
AThe function does not run; it refers to the function itself.
BThe function runs anyway.
CIt causes a syntax error.
DThe program crashes immediately.
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.