**Compound interest program in c** is a simple program to implement in c

In this tutorial we will learn what is mean by compound interest , how to calculate compound interest, compound interest formula, and c program to find compound interest, compound interest problems.

Finding compound interest is very easy same as c program to find simple interest.

Let’s see first introduction to compound interest

**Compound interest definition ?**

Lets see what is compound interest –

Compound interest is calculated on initial the principal amount and also interest on investment of previous periods of loan.

The value compound is reinvesting the interest, rather paying it out.

**Compound interest formula –**

Lets see compound interest formula

**Compound interest = Principal((1+rate/n)^(n*time))**

Where principal is principal amount to be invested

Rate is a rate of interest

N is no of days amount investment

Times is number of time compounded

**Example :-**

Principal = 5000

Rate = 5

No of year = 10

Times = 12

now calculate compound interest

Compound interest =Principal((1+rate/n)^(n*time))

Compound interest = 8235.04

**Logic to calculate compound interest in c programming :**

First we take a input principal, rate, no of years, and times from user and using compound interest formula we calculate compound interest and print the result.

**Algorithm to calculate compound interest **

1. Start

2. Declare variables

3. Take a inputs from user principal, rate, no, and times

4. Calculate compound interest using formula.

5. Print Compound interest

6. Stop

## C program to find compound interest

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
#include<stdio.h> #include<math.h> main() { //CI=P((1+r/n)^(nt)) float compoundInterest,principal,rate,time; int n; printf("Enter Principal\n"); scanf("%f",&principal); printf("Enter rate in percentage\n"); scanf("%f",&rate); printf("Enter time in years(demcimals)\n"); scanf("%f",&time); printf("Enter number of times interest is compounded per year\n"); scanf("%d",&n); compoundInterest=(float)(principal*(pow((1+(rate/(100*n))),(n*time)))); printf("Compound Interest is %f\n",compoundInterest); } |

**Output :**

**Explanation :**

**1. First statement in c program we include a header files.**

**2. Next write a main function .**

**3. Declare variables**

compoundInterest => to store compound interest

principal => to store principal amount

rate => to store rate of interest

time => to store no of years for compound interest

n => to store a no of times interest compounded

**4. Next take a input from user a values for principal, rate, no of years and no times interest compounded.**

printf(“Enter Principal\n”);

scanf(“%f”,&principal);

printf(“Enter rate in percentage\n”);

scanf(“%f”,&rate);

printf(“Enter time in years(demcimals)\n”);

scanf(“%f”,&time);

printf(“Enter number of times interest is compounded per year\n”);

scanf(“%d”,&n);

**5. Example :-**

Suppose user inputs

principal = 5000

rate = 5

time = 10

n = 12

**6. Next using formula calculate compound interest**

**compoundInterest=(float)(principal*(pow((1+(rate/(100*n))),(n*time))));**

This is a simple way to write a expression in c programming.

compoundInterest=(float)(5000*(pow((1+(5/(100*12))),(12*10))));

compoundInterest = 8235.047852

**7. Next print the compound interest that we calculated using formula.**

printf(“Compound Interest is %f\n”,compoundInterest);

=> Compound Interest is 8234.047852

## Leave a Reply