Back to C++ Notes
Topic #75

Default Parameter


Default Parameter Value

You can also use a default parameter value, by using the equals sign (=).

If we call the function without an argument, it uses the default value ("Norway"):

Example

void myFunction(string country = "Norway") {
  cout
<< country << "\n";
}

int main() {
  myFunction("Sweden");

myFunction("India");
  myFunction();

myFunction("USA");
  return 0;
}

// Sweden
//
India
// Norway
// USA

Note: A parameter with a default value, is often known as an "optional parameter". From the example above, country is an optional parameter and "Norway" is the default value.

Want to go beyond the notes?

Join Coding Now Tech Institute's C++ course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Default Parameter – FAQs

Quick answers about learning Default Parameter in C++.

This free note from Coding Now Tech Institute explains Default Parameter in C++ — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every C++ topic on Coding Now Tech Institute, including Default Parameter, is 100% free with no signup required.
With focused practice, most students grasp Default Parameter in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now