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.
SOURCE CODE : :
float principal, rate, year, ci;
printf("Enter principal: ");
printf("Enter rate: ");
printf("Enter time in years: ");
//calculate comp. interest
printf("Comp. interest is: %f\n",ci);
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