C Program For Compound Interest

Last Updated : 17 Aug, 2026

Compound interest is the interest calculated on both the original principal and the interest accumulated in previous periods. In other words, it is interest earned on interest.

  • The accumulated interest is added to the principal, so the interest for the next period is calculated on the increased amount.
  • Unlike simple interest, compound interest grows over time because the interest is repeatedly added to the principal.

Formula to calculate compound interest annually is given by: 

Amount= P(1 + R/100)t
Compound Interest = Amount - P

Where, 

  • P is principal amount 
  • R is the rate and 
  • T is the time span

Example:

Input: Principal (amount): 1200
Time: 2
Rate: 5.4

Output: Compound Interest = 133.099243

c
#include <stdio.h>

// For using pow function we must 
// include math.h
#include<math.h> 

// Driver code
int main() 
{
  // Principal amount
  double principal = 10000; 

  // Annual rate of interest
  double rate = 5; 

  // Time
  double time = 2; 

  // Calculating compound Interest
  double Amount = principal * 
                  ((pow((1 + rate / 100), 
                    time)));
  double CI = Amount - principal;
 
  printf("Compound Interest is : %lf",CI);
  return 0;
}

Output
Compound Interest is : 1025.000000
Comment