C Program to Calculate Simple Interest

How to write a C program to calculate simple interest with example code. Before we get into the C program to calculate simple interest example, let us understand the mathematical formula to calculate simple interest:

Simple Interest = (Principal Amount * Rate of Interest * Number of years) / 100

 

C Program to Calculate Simple Interest:

Below C program allows the user to enter the “principal amount”, “rate of interest”, and the “number of years”. We will calculate simple interest by using entered values with the help of above mentioned simple interest formula.

#include<stdio.h>

int main()
{
    float principalAmt, rateOfInterest, Time_Period, simpleInterest,monthlyEmi;

    printf("Please enter the Principal Amount : = ");
    scanf("%f", &principalAmt);

    printf("Please Enter Rate Of Interest : = ");
    scanf("%f", &rateOfInterest);

    printf("Please Enter the Time Period in Years : = ");
    scanf("%f", &Time_Period);

    simpleInterest = (principalAmt * rateOfInterest * Time_Period) / 100;
    printf("Simple Interest for Principal Amount %.2f is = %.2f\n", principalAmt, simpleInterest);


    monthlyEmi = (principalAmt+simpleInterest)/(Time_Period*12);

    printf("Monthly EMI for using simple interest is = %.2f\n",monthlyEmi);


    return 0;
}

Output:

Please enter the Principal Amount: = 730000
Please Enter Rate Of Interest : = 8.85
Please Enter the Time Period in Years: = 5
Simple Interest for Principal Amount 730000.00 is = 323025.00
Monthly EMI for using simple interest is = 17550.42

Leave a Reply

Your email address will not be published. Required fields are marked *