C Program to Calculate Compound Interest

In this article, we are going to learn how to calculate Compound Interest using a C language program. The Compound Interest can be calculated by using a simple formula. The formula for Compound interest is:

Formula to calculate Compound Interest

Amount = Principal(1 + Rate/Num)^(NumTime)


  • Amount: This is the amount value including interest and principal.
  • Principal: This is the amount borrowed on interest.
  • Rate: This is the rate in % at which interest will be charged
  • Num: This number tells us how interest will be compounded. For example, Quarterly, Half Yearly, Annually.
  • Time: This is the time for which this money is borrowed.

The Compound interest earned can be calculated with the below calculation once you have the Amount.

CompoundInterest = Amount - Principal;

C Program to Calculate Compound Interest

Now let us see this formula in action using the C program below. We are asking the user to enter Principal, Interest, rate, and Time values and calculating the compound interest by using the above formula.

int main()

     float PrincipalAmt, time, rate, num, Amount;
     printf("Please enter the Principal Amount: ");
     printf("Please enter the Rate of Interest: ");
     printf("Please enter the Time: ");
     printf("Please enter the Number of Compounding: ");

    Amount = PrincipalAmt*pow( (1+(rate/num)), (num*time));

    printf("The Amount will become : %.2f\n",Amount);

    long CompoundInterest = Amount - PrincipalAmt;

    printf("The Compound Interest Earned is : %.2f\n",CompoundInterest);

   return 0;