I am taking my first programming class this semester and I can't figure out what is going on with my program. I have to write a program that calculates the total amount of money after so many years with interest. The formula is y=p*(1+r)^n
Anyways, whenever I run my code it comes up as "_ has stopped working" and closes.
Here is my code:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main (void)
{
double p, r, n, y;
printf("Enter the interest rate>");
scanf("%lf", r);
printf("Enter the principle amount of money invested>");
scanf("%lf", p);
printf("Enter the number of years invested>");
scanf("%lf", n);
y = pow(p*(1+r),n);
printf("The total amount of money is %f.\n", y);
system("PAUSE");
return (0);
}
I have tried googling it and it seems like it might have something to do with "initializing", but I'm not sure what that means or how to do it. Any help is greatly appreciated!