What is a default argument in C++?

19 views
  • An argument that is passed to a function by default if no value is specified. (Correct Answer)
  • An argument that is passed to a function if its value is unspecified.
  • An argument that is passed to a function if it is not specified in the function call.
  • An argument that is passed to a function by reference.

Explanation

Correct answer: a) An argument that is passed to a function by default if no value is specified.

Explanation: A default argument in C++ is a value that is assigned to a function parameter if no argument is passed in the function call. This allows us to define a single function that can be called with different numbers of arguments, without requiring the user to specify all of them.

Comments (0)

No comments yet. Be the first to comment!

Want to practice more?

Explore thousands of MCQs across every exam category on Exams Nepal.

Find More MCQs