*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?**

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

**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,the below program is successfully compiled and run on the Windows System to produce output.Let’s check out the program below.

### SOURCE CODE : :

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#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 ci=principal*((pow((1+rate/100),year)-1)); printf("Comp. interest is: %f\n",ci); return 0; } |

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

*Output : :*

*Output : :*

1 2 3 4 |
Enter principal: 10000 Enter rate: 10.25 Enter time in years: 5 Comp. interest is: 6288.943359 |

## Leave a Reply