To write a C++ program to implement functions with default arguments.
Algorithm:
Step 1: Start the program.
Step 2: Declare the function add with default arguments.
Step 3: Call the function with defaults arguments inside the main function.
Step 4: stop the program.
Program Code:
#include<iostream.h>
#include<conio.h>
void add(int=10, int=20)
void main()
{
clrscr();
add();
add(30);
getch();
}
void add(int a, int b)
{
int c;
c=a+b;
cout<<”The value is”<<c<<endl;
}
Output:
The value is 30
The value is 50
Post A Comment:
0 comments: