Recall & Review
beginner
What is a return value in C++?
A return value is the result a function sends back to the part of the program that called it. It lets the function give information after finishing its task.
Click to reveal answer
beginner
How do you specify the type of a return value in a C++ function?
You write the type before the function name. For example,
int means the function returns an integer number.Click to reveal answer
intermediate
What happens if a function has a return type but no return statement?
If a function promises to return a value but does not use
return, the program may behave unpredictably or cause an error.Click to reveal answer
intermediate
Can a function return multiple values directly in C++?
No, a function returns only one value directly. To return multiple values, you can use structures, classes, or output parameters.
Click to reveal answer
beginner
What does the
void return type mean?It means the function does not return any value. It just performs actions without sending back a result.
Click to reveal answer
What keyword is used to send a value back from a function in C++?
✗ Incorrect
The
return keyword is used to send a value back from a function.If a function is declared as
int add(), what must it do?✗ Incorrect
The function must return an integer value because its return type is
int.What is the return type of a function that does not return any value?
✗ Incorrect
The
void return type means the function returns no value.Which of these can a C++ function return directly?
✗ Incorrect
A function can return only one value directly.
What happens if a function with a non-void return type does not have a return statement?
✗ Incorrect
Not returning a value when expected causes undefined behavior or errors.
Explain what a return value is and why it is important in C++ functions.
Think about how functions share results with the rest of the program.
You got /3 concepts.
Describe how to handle returning multiple pieces of information from a C++ function.
Consider containers or references to send back more than one value.
You got /3 concepts.