C Program to find Simple Interest

In this program, we will learn how to calculate the simple interest for a given amount at a given rate for a period of time in years. The simple interest can be calculated by the below given formula

S.I. = (Principle * Rate * Time) / 100

We will use this formula in our program

Program

#include<stdio.h>
void main()
{
    float P , R , T , SI ;
    printf("Enter the value of Principle: ");
    scanf("%f",&P);
    printf("Enter the value of rate: ");
    scanf("%f",&R);
    printf("Enter the time in years: ");
    scanf("%f",&T);

    SI = (P*R*T)/100;
    printf("The Simple Interest is : %f", SI);

}

Output:

Enter the value of Principle: 1000
Enter the value of rate: 4
Enter the value of time: 2
The Simple Interest is : 80.000000

Explanation

  • We have declared four float variables named P, R, T, and SI for Principle, Rate of interest, Time , and Simple Interest respectively.
  • In the next step, we have taken the user inputs for principle, rate and time (In years).  We have displayed the messages using the printf() function and the values are stored in the variables using the scanf() function.
  • To calculate the simple interest, we have used the above-mentioned formula and stored the result in a variable named SI.
  • Finally, we have printed the result using the printf() function.