Recall & Review
beginner
What are function parameters in C++?
Function parameters are variables listed in a function's definition. They act as placeholders for the values (arguments) passed to the function when it is called.
Click to reveal answer
beginner
What is the difference between a parameter and an argument?
A parameter is the variable in the function definition. An argument is the actual value passed to the function when calling it.
Click to reveal answer
beginner
How do you pass parameters by value in C++?
Passing by value means the function gets a copy of the argument. Changes inside the function do not affect the original variable.
Click to reveal answer
intermediate
What does passing parameters by reference mean?
Passing by reference means the function receives the actual variable's address. Changes inside the function affect the original variable.
Click to reveal answer
intermediate
What is a default parameter in a function?
A default parameter has a value assigned in the function declaration. If the caller does not provide an argument, the default value is used.
Click to reveal answer
What happens when you pass a parameter by value to a function?
✗ Incorrect
Passing by value means the function works with a copy, so the original variable stays unchanged.
How do you declare a function parameter to be passed by reference in C++?
✗ Incorrect
Using & after the type declares a reference parameter, allowing the function to modify the original variable.
What is the purpose of default parameters in functions?
✗ Incorrect
Default parameters let the caller skip some arguments, using predefined default values instead.
Which of these is a correct function declaration with a default parameter?
✗ Incorrect
The correct syntax assigns a default value after the parameter type and name.
If a function parameter is declared as int *ptr, how is the argument passed?
✗ Incorrect
int *ptr means the function receives a pointer to an int, allowing indirect access to the variable.
Explain the difference between passing parameters by value and by reference in C++.
Think about whether the function can change the original variable or just a copy.
You got /4 concepts.
Describe how default parameters work and why they are useful.
Consider how you can call a function with fewer arguments than parameters.
You got /4 concepts.