Cpp : Default Arguments 3

Example:4

#include <iostream>

using namespace std;
void cal(int a,int b=20,int c=30)
{
    int s;
    s=a+b+c;
    cout<<"Sum ="<<s<<endl;
}
int main()
{
    //cal();//1 //error (Atleast one arguments has to be passed)
    cal(10);//2
    cal(11,22); //3
    cal(11,22,33); //4
    return 0;
}
/* Output */

Sum =60
Sum =63
Sum =66