Skip to content
Home » C Program to Calculate Compound Interest

C Program to Calculate Compound Interest

Learn about C Program to Calculate Compound Interest in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

C Program to Calculate Compound Interest

Compound interest is computed by multiplying the original principal amount by one plus the annual interest rate multiplied by the number of compound periods multiplied by one. Following that, the total initial loan amount is removed from the resultant value.

Source code:

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

   double princ, amount;
   float rate, time;
   int n;

   printf("Enter principal amount: ");
   scanf("%lf",&princ);
   printf("Enter rate, time and number of times: ");
   scanf("%f %f %d",&rate, &time, &n);

   // calculating compound interest
   amount = princ*pow( (1+(rate/n)), (n*time));

   // print result
   printf("Amount=%.2lf",amount);

   return 0;
}

Output:

Enter principal amount: 5000
Enter rate, time and number of times: 0.2 5 6
Amount=10234

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
C Program to Calculate Simple Interest
C Program to Find Sum and Average of 3 Numbers