Answer to Question #23618 in C++ for Yanna

Question #23618
how to program compound interest using only p,r,t,and n(no.of times compounded each year?NO use of math.h just stdio.h.
1
Expert's answer
2013-02-04T11:24:03-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS