Tuesday 7 July 2020

Compound Interest Calculation Program In C++

Compound Interest Calculation Program In C++

Code:
#include<iostream>
#include<iomanip>
#include<cmath>
int main()
{

int fixed;
cout<<fixed<< setprecision(2);
double principal{1000.00};
double rate{0.05};
cout<<"Initial principal"<<principal<<endl;
cout<<"Initial rate "<<rate<<endl;
cout<<" Year " <<setw(20)<<" Amout on deposit"<<endl;
for(int year{1}; year<=10; year++){
double amout = principal*pow(1.0 +rate,year);

cout<<setw(4)<<year<<setw(20)<<amount<<endl;
}

return 0;

}

No comments:

Post a Comment