I'm very new to C and I don't quite get it yet. This is my assignment and below is my code.
A person invests $1,000.00 in a saving account yielding 5% interest. Assume that all interest is left on deposit in the account, calculate and print the amount of money in the account at the end of each year for 10 years. Use the following formula for determining these amounts:
a = p(1+r)n
where p is the original amount invested, r is the annual interest rate, n is the number of years, a is the amount on deposit at the end of the nth year
#include <stdio.h>
#include <math.h>
int main(){
double a, p, n;
double r=(1 + (1/20));
p=1000;
for(n=1; n<=10; n++){
a = (p*(r)^n);
printf("%f, %f, %f\n", a, n,r);
}
return 0;
}
When I try to compile it, I get the following error:
error: invalid operands to binary expression
('double' and 'double')
a = (p*(r)^n);
~~~~~^~
Can anyone help me figure out what this means and what I should do? Thank you!