C program to calculate simple interest

In this article, we are going to discuss how to calculate simple interest. So let’s start!

C program to calculate simple interest

For example –

Input :

So we are going to take user input first so first, we take all the user input such as the value of principal simple interest and time so we take
Enter the principal value:1000
Enter the interest rate:2.2
Enter the time:2yr

Logic:

Before starting the program, we have to know about the formula of simple interest that is :

SI = Principle * Rate * Time / 100

So in this formula basically –

SI – SI is the total simple interest.

P – the principal is the sum of money on which interest is to be earned.

R – rate is the percentage at which interest occurs over time.

T – time is the length of the period over time.

Output :

So according to the above input, we get these types of input that is –
Simple interest is 44.000000

So let’s start to implement this formula in our program:

Example 1 –

// C program to calculate simple interest.

#include<stdio.h>
int main(){
float principle, time, interest_rate, simple_interest ;
printf(“Enter the principle value :”);
scanf(“%f”, &principle);
printf(“Ente the interest rate :”);
scanf(“%f”, &interest_rate);
printf(“Enter the time :”);
scanf(“%f”, &time);
simple_interest = (principle * time * interest_rate) /100;
printf(“Simple interest is %f “, simple_interest);
return 0;
}

Output –

Enter the principal value:1000
Enter the interest rate:2.2
Enter the time:2yr
Simple interest is 44.000000

steps to follow for the above program are :

Step 1: First we take a float type variable to take input from the user to take an amount of principle, rate, and time and then to get the value of simple interest we use a simple interest variable.

Step 2: Then we use scanf() statement to store the values of the variable. We can see from the above program we simply use scanf() statements four times because we print simple input at a time.

Step 3: Then we simply apply the formula to calculate the simple interest. So the formula is :
simple_interest = (principle * time * interest_rate) /100;

Step 4: After these steps, we simply use scanf() to print the final answer.

In this way, we simply understand how to calculate simple interest by taking user input. I hope these things are clear to you. So for now keep learning and keep exploring.