Write a program tart has 2 factors One unction computes the
Solution
//Program calulate interests
//Header file required to compute the expression
#include <iostream> // input output header
#include<math.h> //math function header
void quarter(int p,int r); //function declaration to compute qurter wise expression
void continuos(int p,int r); //function declaration to continuos qurter wise expression
using namespace std;
int main() //main function begins
{
int p,r; //varible declarations
cout<<\"Enter any Principal amount: \"<<endl; //prompt for principle amount value
cin>>p; //read pvalue
cout<<\"Enter Rate of interest: \"<<endl; //prompt for rate of interest in decimal
cin>>r; //read r
quarter(p,r); //calling function qurter
continuos(p,r); //calling function continuos
return 0;
}
void quarter(int p,int r) //function defination
{
double y1,y2,y3,y4,y5;
double d=(double)r/100; //convert rate into fraction
y1= p*pow((1+d/4),4*1) ; //A = P (1 + r/n) ^nt, t indicates time year wise, n indicates how many times compond per year,r means rate ,p means principal
y2= y1*pow((1+d/4),4*1);
y3= y2*pow((1+d/4),4*1);
y4= y3*pow((1+d/4),4*1);
y5= y4*pow((1+d/4),4*1);
cout << \"Quarterly Compound Intereset Rates Year wise \" <<endl;
cout << \"Year1 : \" <<y1<<endl;
cout << \"Year2 : \" <<y2<<endl;
cout << \"Year3 : \" <<y3<<endl;
cout << \"Year4 : \" <<y4<<endl;
cout << \"Year5 : \" <<y5<<endl;
}
void continuos(int p,int r) //function defination
{
double y1,y2,y3,y4,y5;
double d=(double)r/100;
y1= p* exp (d*1); //A = P * e ^rt ,e means exponent,r means rate ,t means time in year format
y2= y1* exp (d*1);
y3= y2* exp (d*1);
y4= y3* exp (d*1);
y5= y4* exp (d*1);
cout << \"Continuos Compound Intereset Rates Year wise \" <<endl;
cout << \"Year1 : \" <<y1<<endl;
cout << \"Year2 : \" <<y2<<endl;
cout << \"Year3 : \" <<y3<<endl;
cout << \"Year4 : \" <<y4<<endl;
cout << \"Year5 : \" <<y5<<endl;
}
Output :
Enter any Principal amount:
5000
Enter Rate of interest:
5
Year1 : 5254.73
Year2 : 5522.43
Year3 : 5803.77
Year4 : 6099.45
Year5 : 6410.19
Year1 : 5256.36
Year2 : 5525.85
Year3 : 5809.17
Year4 : 6107.01
Year5 : 6420.13

