2013-02-02T13:50:04-05:00
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
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 !
Learn more about our help with Assignments:
C++
Comments