Answer:
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int a=1;
while(a==1){
float P=0.0,R=0.0,T=0.0,A=0.0,n=0.0,nt=0.0;
cout<<"Enter your Initial Investment Amount : ";
cin>>P;
cout<<"Enter your Rate of Annual interest : ";
cin>>R;
cout<<"Enter No. of times the interest is compound : " ;
cin>>n;
cout<<"Enter Time (years) : ";
cin>>T;
nt=n*T;
A=P*pow((1+R/n),(nt));
cout<<"After "<<T<<" years, the initial investment of "<<P<<" is : "<<A;
cout<<"\\Enter 1 to continue or exit by pressing any other button";
cin>>a;
}
return 0;
}
Step-by-step explanation:
- Get the essential values from user as an input and store them in variables.
- Apply the following formulas to calculate years and initial investment.
- nt=n*T;
- A=P*pow((1+R/n),(nt));
- Finally display the results.