# C Program to Calculate Compound Interest

In this article, we are going to learn how to calculate Compound Interest using a C language program. The Compound Interest can be calculated by using a simple formula. The formula for Compound interest is:

#### Formula to calculate Compound Interest

```Amount = Principal(1 + Rate/Num)^(NumTime)
```

#### Where:

• Amount: This is amount value including interest and principal.
• Principal :This is the amount borrowed on interest.
• Rate :This is the rate in % at which interest will be charges
• Num : This number tells us how interest will be compounded. For example, Quarterly,Half Yearly , Annually.
• Time : This is time for which this money is borrowed.

The Compound interest earned can be calculated with the below calculation once you have the Amount.

```CompoundInterest = Amount - Principal;
```

### C Program to Calculate Compound Interest

Now let us see this formula in action using the C program below.

```#include<stdio.h>
#include<math.h>
int main()
{

float PrincipalAmt, time, rate, num, Amount;

printf("Please enter the Principal Amount: ");
scanf("%f",&PrincipalAmt);
printf("Please enter the Rate of Interest: ");
scanf("%f",&rate);
scanf("%f",&time);
printf("Please enter the Number of Compounding: ");
scanf("%f",&num);

Amount = PrincipalAmt*pow( (1+(rate/num)), (num*time));

printf("The Amount will become : %.2f\n",Amount);

long CompoundInterest = Amount - PrincipalAmt;

printf("The Compound Interest Earned is : %.2f\n",CompoundInterest);

return 0;
}
```

Output

```
```