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
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: