by Dinesh Thakur Category: C Programming (Pratical)

If the amount deposited in a bank (i.e., principal), number of years and interest rate are denoted asp, n and r, respectively, compound interest (compounded annually) as p(1+r/100)n. The program segment given below calculates and prints compound interest on deposit.

The scanf statement reads the amount deposited (p of type float),interest rate (r of type float),number of years (n of type float)

#include <stdio.h>
#include <math.h>
void main( )
       float   p, r, n, i,f;
       printf("P1ease enter a value for the prinipal (P) : " ) ;
       scanf ( "%f", &p);
       printf("P1ease enter a value for the interestrate ( r ) : " ) ;
       scanf ("%f" , & r );
       printf("P1ease enter a value for the number of years (n) : " ) ;
       scanf ( " % f ", n) ; /* calculate i,then f */
       i= r/100;
       f = p * pow((1 + i ) , n ) ;
       printf ( "\nThe  final  value (F) is : %.2f\n", f ) ;

Find the Compound Interest

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Search Content