C program to calculate Simple Interest with explanation

In this tutorial, we are going to learn the writing program in c to calculate the Simple Interest. Simple Interest is a mathematical term and we have a mathematical formula for this calculation.

Before starting writing the program let’s understand simple interests.

What is Simple Interest?

Simple interest is a method to calculate the interest charged on a loan. It is calculated by multiplying the interest rate by the principal by the number of days that elapse between payments.

Simple Interest Formula:

SI = (P*T*R)/100

Where,

P is principle amount

T is the time duration

R is the rate of interest

Example of how we can calculate simple interest

Input

Enter principle: 1200

Enter time: 2

Enter rate: 5.4

Output

Simple Interest = 129.600006

Logic we are following to calculate simple interest

  • We are taking Principle amount, time and rate of interest as an input.
  • Now after taking input we are simply calculating simple interest using formula SI = (principle * time * rate) / 100.
  • After calculating SI using above formula we are printing the value which is our program output.

Program in C to calculate Simple Interest

#include <stdio.h>
int main()
{
    float p, t, r, SI;
    printf("Program to calculate Simple Interest\n");
    printf("Enter principle amount: ");
    scanf("%f", &p);
    printf("Enter time (in years): ");
    scanf("%f", &t);
    printf("Enter rate: ");
    scanf("%f", &r);
    SI = (p * t * r) / 100;
    printf("Simple Interest = %.2f", SI);
    return 0;
}

Output

Program to calculate Simple Interest
Enter principle amount: 1000
Enter time (in years): 3
Enter rate: 5
Simple Interest = 150.00

[wpusb]