Test Your Knowledge (Ch 11)
The following questions are based on what we have learned so far in Chapter 11 – Functions in C. To test your understanding, try answering the following questions. The explanations are also provided to each question so you can always check the correctness of your answers. All the best 👍
Question 6
What is the key difference between call by value and call by reference?
Call by value modifies the actual arguments, while call by reference does not.
Call by reference passes a copy of the arguments to the function.
Call by value passes a copy of the arguments, while call by reference passes the actual arguments.
There is no difference between them.
explanation
In call by value, the function operates on a copy of the actual arguments, so changes do not affect the original value. In call by reference, the function operates on the actual arguments, so changes affect the original value.
Question 8
What is the difference between formal and actual parameters in C?
Formal parameters are used during the function definition, while actual parameters are used during the function call.
Actual parameters are used during the function definition, while formal parameters are used during the function call.
Both are used interchangeably.
None of the above.
explanation
Formal parameters are the variables defined in the function’s definition, whereas actual parameters are the values passed to the function during the call.
Leave a comment