C Program to Find Compound Interest

bookmark

/*
 * C Program to find compound interest using formula
 */
#include <stdio.h>
#include <math.h>
 
int main()
{
    double Principal;
    printf("Enter the Principal Amount: ");
    scanf("%lf", &Principal);
 
    double Rate;
    printf("Enter the Interest Rate: ");
    scanf("%lf", &Rate);
 
    double Time;
    printf("Enter the Time Period(in Years): ");
    scanf("%lf", &Time);
 
    // Calculating compound interest
    double Amount;
    Amount = Principal * pow((1 + Rate / 100), Time);
 
    double Compound_Interest;
    Compound_Interest = Amount - Principal;
    printf("The Compound Interest is %.2lf ",Compound_Interest);
 
    return 0;
}

 

Output


Enter the Principal Amount: 5000
Enter the Interest Rate: 10
Enter the Time Period(in Years): 2
The Compound Interest is 1050.00