## Compound Interest – C Program

### write a c program of calculate compound interest of given amount

The compound interest is a interest of interest.

The Compound Interest is interest of the first period, add it to the total basic amount, and then calculate the interest for the next period, and so on…..

```
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float amt,rate,yr,ans,cans;
int i;
printf("Enter your basic amount : \n");
scanf("%f",&amt);
printf("Enter your interest rate : \n");
scanf("%f",&rate);
printf("Enter number of year for calculate interest: \n");
scanf("%f",&yr);
ans=1+(rate/100);
cans=1;
for(i=1;i<=yr;i++)
{
cans=cans*ans;
}
cans=amt*cans-amt;
printf("The total compound interest is : %.2f",cans);
}
```

The c program output is :

```
Enter your basic amount :
10000
Enter your interest rate :
10
Enter number of year for calculate interest:
2
The total compound interest is = 2100
```