I found the formula on the net that explains the way to compute compound interest a=p(1+r\n)nt where a = amount after time t,

p = principal amount, r = annual interest rate, n = number of time the interest is compounded per year and t = number of years. Do I need to declare another variable? I'm still a little confused because my program below displays the following result:

"Your balance after 2289404 years with an interest rate of Inf would be $-0.000000."

...if I enter a dollar amount deposited of 1500.00 with .07 interest and 20 years for the input.

Code:

/*
Filename: balance.c
Description: Displays the balance with interest compounnded annually,
after number of years entered.
*/
# include <stdio.h>
# include <math.h>
void introduction (void);
double ComputeBalance (double a, double r, int n, double t);
int main()
{
/*Allocate memory for data*/
introduction ();
double a,r,t;
int n;
/*Prompt user for data*/
printf ("\nEnter the the dollar amount deposited: $");
scanf ("%lf",&a);
printf ("\nEnter the interest rate:");
scanf ("%lf",&r);
printf ("\nEnter the number of years:");
scanf ("%d",&n);
/*Processing and display results*/
printf ("\nYour balance after %d years with an\n");
printf ("interest rate of %lf would be"
" $%lf\n",ComputeBalance(n,r,t,a));
return 0;
}
void introduction (void)
{
printf ("\nThis program displays the balance with interest,\n");
printf ("compounded annually after number of years entered.");
}
double ComputeBalance(double a,double r, int n, double t)
{
return t=a*1+pow(r,n);
}