#include <stdio.h>int main(){
floatp = 0, r = 0;
intt = 0, n = 0;
printf("Enterprincipal amount (initial investment): ");
scanf("%f",&p);
printf("Enterannual nominal interest rate (as a decimal, not in percentage): ");
scanf("%f",&r);
printf("Enternumber of years: ");
scanf("%d",&t);
printf("Enternumber of times the interest is compounded per year: ");
scanf("%d",&n);
for(inti = 0; i < t*n; i++){
p+= p*r/n;
}
printf("
Thebalance after %d year(s): %f
", t, p);
return0;
}
Comments
Leave a comment