LearnFrenzy
Sign in Take a free test

C Const · const MCQ · Question 9

What does const do on a by-value parameter? Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links