Default arguments function in C++


Setting up a function's parameters with some default values is called as default arguments function C++ program of default arguments functions

#include<iostream> using namespace std; int sum(int a, int b, int c = 0, int d = 0) { return (a + b + c + d); } int main(){ cout<<sum(2, 5)<<endl; cout<<sum(2, 7, 1)<<endl; cout<<sum(34, 6, 7, 1)<<endl; }

Output:-

7
10
48

Explanation of the program