# C Program to Calculate Compound Interest

C program to calculate compound interest; Through this tutorial, you will learn how to calculate compound interest in the c program with the help of function, and normal formula.

## Programs to Calculate Compound Interest in C

• Algorithm to Calculate Compound Interest
• C Program to Calculate Compound Interest using Formula
• C Program to Calculate Compound Interest using Function

### Algorithm to Calculate Compound Interest

Use the following algorithm to write a program to calculate compound interest; as follows:

• Get input principle amount and store in some variable.
• Get input time and store in some variable..
• Get input rate and store in some variable..
• To calculate compound interest using formula `CI = principal*((1+rate/100)time-1)`.
• Finally, print the result of compound interest.

### C Program to Calculate Compound Interest using Formula

```/* C program to enter P, T, R, and calculate Compound Interest */

#include <stdio.h>
#include <math.h>

int main()
{
float principle, time, rate, CI;

/* Input principle, rate and time */
printf("Enter principle (amount): ");
scanf("%f", &principle);

printf("Enter time: ");
scanf("%f", &time);

printf("Enter rate: ");
scanf("%f", &rate);

/* Calculate compound interest */
CI = principle * (pow((1 + rate / 100), time));

/* Print the resultant value of CI */
printf("Compound Interest = %f", CI);

return 0;
}```

The output of the above c program; as follows:

```Enter principle (amount): 5000
Enter time: 7
Enter rate: 9
Compound Interest = 9140.197266```

### C Program to Calculate Compound Interest using Function

```/* C program to enter P, T, R, and calculate Compound Interest using function */

#include <stdio.h>
#include <math.h>

// function for finding compound interest
float CmInt(float p, float r, float t)
{
float ci;
ci = p * (pow((1 + r / 100), t));
return ci; // returning yhe value of ci
}

int main()
{
float principle, time, rate, CI;

/* Input principle, rate and time */
printf("Enter principle (amount): ");
scanf("%f", &principle);

printf("Enter time: ");
scanf("%f", &time);

printf("Enter rate: ");
scanf("%f", &rate);

/* Call function with paramters to Calculate compound interest */
CI = CmInt(principle, rate, time);

/* Print the resultant value of CI */
printf("Compound Interest = %f", CI);

return 0;
}```

The output of the above c program; as follows:

```Enter principle (amount): 1000
Enter time: 5
Enter rate: 5
Compound Interest = 1276.281250```