Q:

Write a C++ Program to Calculate Compound Interest

belongs to collection: C++ Basic Solved Programs

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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)

Where:

 

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.


SOURCE CODE : :

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

#include<iostream>
#include<math.h>
using namespace std;

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

    cout<<"Enter Principle (Amount) :: ";
    cin>>p;
    cout<<"\nEnter Rate of Interest :: ";
    cin>>r;
    cout<<"\nEnter Time Period :: ";
    cin>>t;

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

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

    return 0;
}

OUTPUT : :


/*  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 .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Basic Solved Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C++ program to Find Cube of Number using MACROS... >>
<< C++ Program to find Square Root of a number using ...