need help with simple compound interest calculator

#include<iostream>
using namespace std;



int main(int args, char arg[]){
double money=0.0;
double interest=0.0;
int year=0;
int C=0;
double y;

cout<<"enter how much money is in your account"<<endl;
cin>>money;

cout<<"enter the interest you get"<<endl;
cin>>interest;

cout<<"enter how many years you want calculated"<<endl;
cin>>year;

do{
y=money+(money*interest);
C++;

}while (C<=year);

cout<<y;


system("pause");
}

this is my code it only calculates the first year of interest then thats all it does I've treid every loop but it still had the same problem if anyone could help that would be great
Last edited on
You don't update the money. Try to replace y=money+(money*interest);
with money += (money*interest); and than output money.

Also, you can use direct equation omitting the loop:
money *= pow(1+interest, year);
Thanks allot
Topic archived. No new replies allowed.