27. A person invests $1000.00 in a saving account yielding 5% interest. Calculate and print the amount of money in the accounts at the end of each year for ten years.
Chapter 6:
Looping Structures
Programming Exercise
Problem # 27:
A person invests $1000.00 in a saving account yielding 5% interest. Assuming all interest is left deposit in the account, calculate and print the amount of money in the accounts at the end of each year for ten years. Formula: (a = p(1+r)^n). where
p original amount invested
r Annual Interest rate
n Number of years
a Amount on deposit at the end of nth years
Solution:
#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;
int main()
{
long int p, r, n, a;
p=1000;
for(n=1;n<=10;n++)
{
a=p*(pow(1+0.05,n));
cout<<"\n Amount of money in the account at the end of the "<<n<<" year:"<<a;
}
getch();
}
#include<conio.h>
#include<math.h>
using namespace std;
int main()
{
long int p, r, n, a;
p=1000;
for(n=1;n<=10;n++)
{
a=p*(pow(1+0.05,n));
cout<<"\n Amount of money in the account at the end of the "<<n<<" year:"<<a;
}
getch();
}
Let me know in the comment section if you have any question.
Previous Post:
26. Program that sums the sequence of integers assuming that first integer read specifies the number of values remaining to be entered.
Comments
Post a Comment