Question 9
Back to Exercise
What is the effect of const in int square(const int n)?
- A The caller's variable becomes const
- B Only the function's own copy n cannot be changed inside square() Correct
- C n is passed by reference
- D The function can only be called with literals
Correct Answer: Option B
Arguments are copied, so the caller is never affected either way. The const just stops the function body from reassigning its parameter – and it is not part of the function's type for callers.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!