C Program for simple interest?

Simple Interest is the product of principal amount, rate of interest and the time duration (in years) divided by 100. It is a straightforward method to calculate the interest earned or paid on a loan or investment.

Syntax

Simple Interest = (Principal × Rate × Time) / 100

Where:

  • Principal − The initial amount of money
  • Rate − The interest rate per year (in percentage)
  • Time − The time period (in years)

Example

Let's calculate simple interest with principal = 5000, rate = 4%, and time = 5 years −

#include <stdio.h>

int main() {
    /* Principal amount */
    float principal = 5000;
    
    /* Rate of interest per year */
    float rate = 4;
    
    /* Time in years */
    float time = 5;
    
    /* Calculate simple interest */
    float simple_interest = (principal * rate * time) / 100;
    
    printf("Principal Amount: %.2f
", principal); printf("Rate of Interest: %.2f%%
", rate); printf("Time Period: %.2f years
", time); printf("Simple Interest: %.2f
", simple_interest); return 0; }
Principal Amount: 5000.00
Rate of Interest: 4.00%
Time Period: 5.00 years
Simple Interest: 1000.00

Example with User Input

Here's a program that takes input from the user to calculate simple interest −

#include <stdio.h>

int main() {
    float principal, rate, time, simple_interest;
    
    printf("Enter Principal Amount: ");
    scanf("%f", &principal);
    
    printf("Enter Rate of Interest: ");
    scanf("%f", &rate);
    
    printf("Enter Time Period (in years): ");
    scanf("%f", &time);
    
    /* Calculate simple interest */
    simple_interest = (principal * rate * time) / 100;
    
    printf("
--- Simple Interest Calculation ---
"); printf("Principal: %.2f
", principal); printf("Rate: %.2f%%
", rate); printf("Time: %.2f years
", time); printf("Simple Interest: %.2f
", simple_interest); printf("Total Amount: %.2f
", principal + simple_interest); return 0; }

Key Points

  • Simple interest is calculated using the formula: SI = (P × R × T) / 100
  • The total amount after interest is: Amount = Principal + Simple Interest
  • Use float data type for decimal calculations

Conclusion

Simple interest calculation in C is straightforward using the basic formula. This method provides a linear interest calculation that remains constant throughout the time period.

Updated on: 2026-03-15T11:26:21+05:30

729 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements