Skip to content
Home » Blog » C Program to Calculate Compound Interest

C Program to Calculate Compound Interest

In this Program, you’ll learn how to calculate compound Interest.

To properly understand this Program Calculate Compound Interest you should know the following:

  • Input/Output
  • Arithmetic Operator
  • Data Types

Below is the formula to Calculate the Compound Interest

Compound Interest: Principle * (1 + Rate / 100) time

Calculate Compound Interest formula


In the above formula

P is principle amount
R is the rate and
T is the time span

Logic to Calculate the Compound Interest

Step by step how to find compound interest.

  1. Input principle amount. Store it in some variable say principle.
  2. Input time in some variable say time.
  3. Input rate in some variable say rate.
  4. Calculate compound interest using the above formula.
  5. Finally, print the resultant value of CI.

Program to Calculate Compound Interest

#include <stdio.h>
#include <math.h>

int main()
    float principle, rate, time, CI;

    /* Input principle, time and rate */
    printf("Enter principle (amount): ");
    scanf("%f", &principle);

    printf("Enter time: ");
    scanf("%f", &time);

    printf("Enter rate: ");
    scanf("%f", &rate);

    /* Calculate compound interest */
    CI = principle* (pow((1 + rate / 100), time));

    /* Print the resultant CI */
    printf("Compound Interest = %f", CI);

    return 0;


Enter principle (amount): 1200
Enter time: 2
Enter rate: 5.4
Compound Interest = 1333.099243
C Program to Calculate Compound Interest

Note: The pow() function computes the power of a number.

This Program can be used in making application for banks and calculators.

Ask your questions about how to Calculate the Compound Interest in C and clarify your/others doubts by commenting. Documentation.

Please write to us at [email protected] to report any issue with the above content or for feedback.

Related examples: