C Program to Calculate Compound Interest

  • Write a C program to read principal amount, rate of interest and time and calculate compound interest.
  • Wap in C to find compound interest.

Required Knowledge

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).

  • 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

 * C program to calculate compound interest 
#include <stdio.h>  
#include <math.h>  
int main() {  
    float principle, rate, time, amount, interest; 
     * Take principle, rate and time as input from user
    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 Earned = %.4f", interest);  
    return 0;  

Enter Principle
Enter Rate of Interest
Enter Time
After 3 Years
Total Amount = 129502.9141
Compound Interest Earned = 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