Question #8450

can someone help me with this...the program should exit it shounld go back to the start...help .it is forloop...help me fast...email me the ans..plzzzz.. :)
#include <iostream.h>
#include <stdlib.h>
int main()
{
double princple_amount,rate;
int years,x;
cout<<"Enter initial amount : \t" ;
cin>>princple_amount;
cout <<endl;
cout<< "number of years: \t";
cin>>years;
cout <<endl;
cout<<"Enter interest rate (percent per year):\t" ;
cin>>rate;
cout <<endl;
for ( x=1;x<=years; x=x+1)
{
princple_amount= princple_amount+(princple_amount*rate/100);
}
cout<< " At the end of "<<years<< " years, you will have \t$";
cout<<princple_amount<<endl;
system("PAUSE");
return 0;
}

Expert's answer

#include <iostream.h>

#include <stdlib.h>

int

main()

{

for (int i=0;i<10000;i++){

double

princple_amount,rate;

int years,x;

int

value;

cout<<"Enter initial amount : \t"

;

cin>>princple_amount;

cout

<<endl; cout<<="" "number="" of="" years:="" \t";=""

cin="">>years;

cout <<endl;

cout<<"enter="" interest="" rate="" (percent="" per="" year):\t"="" ;=""

cin="">>rate;

cout <<endl; for="" (=""

x="1;x<=years;" {=""

princple_amount="princple_amount+(princple_amount*rate/100);" }=""

cout<<="" "="" at="" the="" end="" of ="" "<<years<<=""

years,="" you="" will="" have="" \t$";=""

cout<<princple_amount<<endl;

cout<<"If you want

exit, enter 1"<<endl;

cin>>value;

if

(value==1) break;

}

#include <stdlib.h>

int

main()

{

for (int i=0;i<10000;i++){

double

princple_amount,rate;

int years,x;

int

value;

cout<<"Enter initial amount : \t"

;

cin>>princple_amount;

cout

<<endl; cout<<="" "number="" of="" years:="" \t";=""

cin="">>years;

cout <<endl;

cout<<"enter="" interest="" rate="" (percent="" per="" year):\t"="" ;=""

cin="">>rate;

cout <<endl; for="" (=""

x="1;x<=years;" {=""

princple_amount="princple_amount+(princple_amount*rate/100);" }=""

cout<<="" "="" at="" the="" end="" of ="" "<<years<<=""

years,="" you="" will="" have="" \t$";=""

cout<<princple_amount<<endl;

cout<<"If you want

exit, enter 1"<<endl;

cin>>value;

if

(value==1) break;

}

## Comments

## Leave a comment