Write a C++ Program to Calculate Compound Interest

By | 24.12.2016

Calculate Compound Interest

Write a C++ Program to Calculate Compound Interest. Here’s simple Program to Calculate Compound Interest in C++ Programming Language.

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 is source code of the C++ Program to Calculate Compound Interest. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.


/*  C++ Program to Calculate Compound Interest  */

using namespace std;

int main()
    float p,r,t,ci;

    cout<<"Enter Principle (Amount) :: ";
    cout<<"\nEnter Rate of Interest :: ";
    cout<<"\nEnter Time Period :: ";

    ci = p*pow((1+r/100),t);

    cout<<"\nThe Calculated Compound Interest is = "<<ci<<"\n";

    return 0;


/*  C++ Program to Calculate Compound Interest  */

Enter Principle (Amount) :: 385000

Enter Rate of Interest :: 13.89

Enter Time Period :: 4

The Calculated Compound Interest is = 647744

Process returned 0

Above is the source code for C++ Program to Calculate Compound Interest which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.

Thanks for reading the post….

4.6 7 votes
Article Rating
Category: Basic 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