1.21.2012

Compound Interest

Q. Write an interactive program to calculate compound interest.

Ans.

/*c program for calculate compound interest*/
#include<stdio.h>
#include<math.h>
#include<conio.h>
int main()
{
 float p,rate,time,ci;
 printf("Enter principal amount : ");
 scanf("%f", &p);
 printf("Enter interest rate : ");
 scanf("%f", &rate);
 printf("Enter time period in year : ");
 scanf("%f", &time);
 //calculate ci
 ci=p*(pow((1+rate/100),time)-1);
 printf("\nCompound interest = %f",ci);
 return 0;
}

Output :-

Enter principal amount : 48500
Enter interest rate : 6
Enter time period in year : 2
Compound interest = 5994.600098


You might also like to read related program:
  1. Simple Interest C Program

5 comments:

  1. Replies
    1. Why do we put -1? Please tell

      Delete
    2. Power (x, -1)
      Is the same as x raised to -1
      Or mathematically: (1/x)

      Delete
  2. Replies
    1. -1 mention in the calculating formula of Compound interest, so it is not the part of C programming language.

      Delete