C Programs | IT Developer
IT Developer

C Programs



Share with a Friend

Simple Interest and Compound Interest Difference Calculation Program in C

Introduction

In finance, Simple Interest (SI) and Compound Interest (CI) are two different ways of calculating interest:

  • Simple Interest: Interest is calculated only on the principal.

SI = (P × R × T) / 100

 

  • Compound Interest: Interest is calculated on the principal + accumulated interest.

CI = P × (1 + R/100)− P

 

The difference between CI and SI shows how much extra interest is earned (or paid) when interest is compounded.

 

C Program: Simple Interest and Compound Interest Difference Calculation

C

#include <stdio.h>

#include <math.h>   // For pow() function

 

int main() {

    float principal, rate, time, si, ci, difference, amount;

 

    // Input principal, rate and time

    printf("Enter Principal amount: ");

    scanf("%f", &principal);

 

    printf("Enter Rate of Interest (in %%): ");

    scanf("%f", &rate);

 

    printf("Enter Time (in years): ");

    scanf("%f", &time);

 

    // Calculate Simple Interest

    si = (principal * rate * time) / 100;

 

    // Calculate Compound Interest

    amount = principal * pow((1 + rate / 100), time);

    ci = amount - principal;

 

    // Calculate Difference

    difference = ci - si;

 

    // Display results

    printf("\n--- Interest Comparison ---\n");

    printf("Simple Interest = %.2f\n", si);

    printf("Compound Interest = %.2f\n", ci);

    printf("Difference (CI - SI) = %.2f\n", difference);

 

    return 0;

}

Output

 
OUTPUT 1 :
Enter Principal amount: 1000
Enter Rate of Interest (in %): 10
Enter Time (in years): 2

--- Interest Comparison ---
Simple Interest = 200.00
Compound Interest = 210.00
Difference (CI - SI) = 10.00


OUTPUT 2 :
Enter Principal amount: 5000
Enter Rate of Interest (in %): 8
Enter Time (in years): 3

--- Interest Comparison ---
Simple Interest = 1200.00
Compound Interest = 1298.56
Difference (CI - SI) = 98.56


Explanation

  1. User inputs Principal, Rate, and Time.
  2. Formula for SI: (P × R × T) / 100
  3. Formula for CI: P × (1 + R / 100)− P
  4. Difference is calculated as:

Difference=CI−SI

  1. Results are displayed with two decimal places.