C++ program to implement Functions with default argument

0
689

C++ program to implement Functions with default argument

CONSTRUCTION:

  1. Declare a function to compute simple interest (takes 3 arguments).
  2. Assign default value for the third argument.
  3. Read two integers.
  4. Call the function with the values.
  5. Display the result.
  6. Terminate the program.

PROGRAM:

#include<iostream.h>
#include<conio.h
void si(int x,int y,int z=2);
void main()
{ 
int p,n,r;
 cin>>p>>n>>r; si(p,n);
 si(p,n,r);
}
void si(int x,int y,int z)
{
 cout<<”Simple Interest”<<(x*y*z);
}

Leave a Reply