Calculate Simple Interest in C Language

Calculate Simple Interest in C Language

Write a program in C Language to Calculate Simple Interest.

In this C Program we will learn how to make a program in C Language to Calculate Simple Interest. In this program take input principal, rate and time ( p, r , t) from user and find simple interest.

 

Simple Interest Formula

Simple interest formula is given by.

Simple Interest Formula
Where,
P is the principal amount
T is the time and
R is the rate
SI is Simple Interest

 

Logic to calculate simple interest

Step by step descriptive logic to calculate simple interest.

  1. Input principle amount in some variable say p.
  2. Input rate in some variable say r.
  3. Input time in some variable say t.
  4. Find simple interest using formula si = (p * r * t) / 100.
  5. Finally, print the resultant value of si.

 

Program to Calculate Simple Interest

Here is source code of the C program to calculate simple interest. The C program is successfully compiled and run on Windows operating system. The program output is also shown below.

/*    Calculate Simple Interest    */
#include<stdio.h>
int main()
{
	float p;
	float r,t;
	float si;

	printf("Enter your principal amount : ");
	scanf("%f",&p);
	printf("\nEnter your rate of interest : ");
	scanf("%f",&r);
	printf("\nEnter time (in year) : ");
	scanf("%f",&t);
	si = (p * r * t) / 100;
	printf("\nSimple Interest is : %.2f",si);
	return 0;
}

 

Output:

Command Prompt

Enter your principal amount : 1000

Enter your rate of interest : 5

Enter time (in year) : 2

Simple Interest is : 100.00

 

How Simple Interest program works?

  1. #include <stdio.h> includes the standard input output library functions. The printf() and scanf() function is defined in stdio.h .
  2. int main() The main() function is the entry point of every program in c language.
  3. float is a data type in c language. float is used for decimal numbers p, r, t and si are variables. Variable is used for store data value.
  4. printf() The printf() function is used to print data on the console.
  5. scanf() The scanf() function is use to take input from keyboard.

Leave a Reply

Close Menu