C Program to Calculate Compound Interest

In this C program, we will learn about how to read principal amount, rate of interest and time from user and calculate compound interest. We will first read Principle amount, rate of interest and time using scanf function. We will use below mentioned formulae to calculate Compound Interest (CI).

Required Knowledge

  • Amount = P x (1 + R/100)T
  • Compound Interest = Amount - P
Where P, R and T are Principle, Rate of Interest and Time respectively.

C program to calculate compound interest

#include <stdio.h>  
#include <math.h>  
  
int main() {  
    float principle, rate, time, amount, interest; 
    printf("Enter Principle\n");  
    scanf("%f", &principle);
    printf("Enter Rate of Interest\n");  
    scanf("%f", &rate);  
    printf("Enter Time\n");  
    scanf("%f", &time);  
  
    /* Calculates Amount */  
    amount = principle * pow((1 + rate/100), time);  
    /* Calculates Interest  */ 
    interest = amount - principle;
    printf("After %d Years\n", time);
    printf("Total Amount = %.4f\n", amount); 
    printf("Compound Interest = %.4f", interest);  
  
    return 0;  
}
Output
Enter Principle
100000
Enter Rate of Interest
9
Enter Time
3
After 3 Years
Total Amount = 129502.9141
Compound Interest = 29502.9141
Related Topics
C program to calculate simple interest
C program to check year is leap year or not
C program to add digits of a number
C Program to Calculate Area and Perimeter of Parallelogram
C program to find sum of digits of a number using recursion
C Program to Calculate Area of Any Triangle
C Program to Calculate Area and Circumference of a Circle
C Program to Print Fibonacci Series using Recursion
C Program to Compare Two Matrix
List of all C programs