Write a C program to calculate Compound Interest

By | 03.12.2016

C program to calculate compound interest

Write a C program to calculate Compound Interest.In this program , we  are going to calculate interest.So, the question arises  : 

What is compound interest?

It is the addition of interest to the principal sum of a loan or deposit, or in other words, interest on interest. It is the result of reinvesting interest, rather than paying it out, so that interest in the next period is then earned on the principal sum plus previously-accumulated interest.

It may be contrasted with simple interest, where interest is not added to the principal, so there is no compounding.

Annual compound interest formula

The formula for annual compound interest, including principal sum, is:

A = P (1 + r/n) (nt)


A = the future value of the investment/loan, including interest
P = the principal investment amount (the initial deposit or loan amount)
r = the annual interest rate (decimal)
n = the number of times that interest is compounded per year
t = the number of years the money is invested or borrowed for

Note that this formula gives you the future value of an investment or loan, which is compound interest plus the principal. Should you wish to calculate the compound interest only, you need this:

Total compounded interest = P (1 + r/n) (nt) – P

This program will read principal, rate and time in years and then print compound interest on entered principal for given time period.

Here,the below program is successfully compiled and run on the Windows System to produce output.Let’s check out the program below.



#include <stdio.h>
#include <math.h>
int main()
    float principal, rate, year, ci;
    printf("Enter principal: ");
    scanf("%f", &principal);
    printf("Enter rate: ");
    scanf("%f", &rate);    
    printf("Enter time in years: ");
    scanf("%f", &year);
    //calculate comp. interest
    printf("Comp. interest is: %f\n",ci);
    return 0;

Also Read : :Write a C program to calculate EMI or EMI Calculator

Output : :


Enter principal: 10000
    Enter rate: 10.25 
    Enter time in years: 5
    Comp. interest is: 6288.943359
0 0 votes
Article Rating
Category: Advance Programs C Programming Tags:

About Tunde A

My name is Tunde Ajetomobi, a Tech Enthusiast and Growth Hacker. I enjoy creating helpful content that solves problem across different topics. Codezclub is my way of helping young aspiring programmers and students to hone their skills and find solutions on fundamental programming languages.

Notify of

Inline Feedbacks
View all comments