LearnFrenzy
Sign in Take a free test

Functions and Default Arguments · Functions MCQ · Question 5

Which default-argument declaration is valid? Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 5 Back to Exercise

Which declaration is valid?

  • A void f(int a = 1, int b);
  • B void f(int a, int b = 2, int c);
  • C void f(int a, int b = 2, int c = 3); Correct
  • D void f(int a = 1, int b, int c = 3);
Correct Answer: Option C

Once a parameter has a default, all parameters to its right need defaults too, because arguments are matched from the left.

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