#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
float simple(float p,int n=3,float r=0.05);
float compound(float p,int n,float r=0.05);
float p,si,ci,r;
int n;
clrscr();
cout<<"\n Interest on Simple & Compund";
cout<<"\n ******************";
cout<<"\n Enter the Principle Amount:";
cin>>p;
cout<<"\n Enter the Number of year:";
cin>>n;
cout<<"\n Enter the rate of interest:";
cin>>r;
// Call Simple Using Default Arguments
si=simple(p);
cout<<"\n Simple Interest using n and r as Default Arguments:"<<si;
si=simple(p,n);
cout<<"\n Simple Interest using only r as Default Arguments:"<<si;
si=simple(p,n,r);
cout<<"\n Simple Interest without using Default Arguments:"<<si;
//Call Compound using Default Arguments
ci=compound(p,n);
cout<<"\n Compound Interest using only r as default arguments:"<<ci;
ci=compound(p,n,r);
cout<<"\n Compound Interest without using default arguments:"<<ci;
getch();
}
float simple(float p,int n,float r)
{
return(p*n*r/100);
}
float compound(float p,int n,float r)
{
return(p*pow((1+r/100),n)-p);
}
OUTPUT:
-----------
Interest on Simple & Compound
*************************
Enter the Principle Amount:3000
Enter the Numbers of year:2
Enter the rate of interest:0.05
Simple Interest Calculation
********************
Simple interest using n and r as default arguments :4.5
Simple interest using only r as default arguments :3
Simple interest without using default arguments :3
Compound Interest Calculation
************************
Compound interest using only r as default arguments : 3.00075
Compund interest without using default arguments : 3.00075
#include<conio.h>
#include<math.h>
void main()
{
float simple(float p,int n=3,float r=0.05);
float compound(float p,int n,float r=0.05);
float p,si,ci,r;
int n;
clrscr();
cout<<"\n Interest on Simple & Compund";
cout<<"\n ******************";
cout<<"\n Enter the Principle Amount:";
cin>>p;
cout<<"\n Enter the Number of year:";
cin>>n;
cout<<"\n Enter the rate of interest:";
cin>>r;
// Call Simple Using Default Arguments
si=simple(p);
cout<<"\n Simple Interest using n and r as Default Arguments:"<<si;
si=simple(p,n);
cout<<"\n Simple Interest using only r as Default Arguments:"<<si;
si=simple(p,n,r);
cout<<"\n Simple Interest without using Default Arguments:"<<si;
//Call Compound using Default Arguments
ci=compound(p,n);
cout<<"\n Compound Interest using only r as default arguments:"<<ci;
ci=compound(p,n,r);
cout<<"\n Compound Interest without using default arguments:"<<ci;
getch();
}
float simple(float p,int n,float r)
{
return(p*n*r/100);
}
float compound(float p,int n,float r)
{
return(p*pow((1+r/100),n)-p);
}
OUTPUT:
-----------
Interest on Simple & Compound
*************************
Enter the Principle Amount:3000
Enter the Numbers of year:2
Enter the rate of interest:0.05
Simple Interest Calculation
********************
Simple interest using n and r as default arguments :4.5
Simple interest using only r as default arguments :3
Simple interest without using default arguments :3
Compound Interest Calculation
************************
Compound interest using only r as default arguments : 3.00075
Compund interest without using default arguments : 3.00075
0 comments:
Post a Comment