Basic Program 2

Write a program to demonstrate the use of default arguments in function overloading.


#include<iostream>
using namespace std;
void add(int a,int b,int c,int d=4)
{
int ans=a+b+c+d;
cout<<ans<<"\n";
}
void add(int a,int b)
{
int ans=a+b;
cout<<ans<<"\n";
}
void main()
{
add(10,20,30,40);
add(10,20,30);
add(10,20);
}