C Program to calculate Compound Interest
Program
#include<stdio.h>
#include<math.h>
void main()
{
float p, r, t, ci, amt;
printf("Enter the amount, time and rate of interest\n");
printf("Principal amount:\t");
scanf("%f", &p);
printf("Time:\t");
scanf("%f", &t);
printf("Rate of interest:\t");
scanf("%f", &r);
amt = p * pow((1 + r / 100), t);
ci = amt - p;
printf("Compound Interest:\t%f\n", ci);
printf("Total amount payable:\t%f\n", amt);
}
Output
Enter the amount, time and rate of interest
Principal amount: 1500
Time: 3
Rate of interest: 2.3
Compound Interest: 105.898804
Total amount payable: 1605.898804