C Program to find simple interest in c program

For a better understanding of this C programming example, we always recommend you to learn the basic topics of C programming listed below:

What is simple interest? How is it calculated?

This C program calculates the simple interest, given the principal amount, rate of interest, and time. Simple interest is the interest we need to give for a certain principal amount that we took from a bank or some financial institution. Simple interest is calculated by using the formula "si = p*n*r /100". Where

  • 'p' is the Principal amount,
  • 'n' is the number of years.
  • 'r' is the rate of interest for the amount.

Let us take an example to understand better, suppose the principal amount 'is 1000 and the number of years is 5 and the rate of interest is 10 then we calculate the simple interest as (1000 * 5 * 10)/100. = 500, that means we have to pay 500 for 5 years. Similarly to calculate Simple Interest half-yearly and quarterly, principal amount, rate of interest, and time are needed.

How we calculate simple interest using the c program

Now let's see how we use this logic in the C program. After accepting user input for the principal amount, rate of interest, and time. We define variables as float datatype. In this C program, we use 5.2 f precision, which 5 represents the total number of digits and 2 the number of decimal points. It is for getting a better viewing experience in the simple interest.

The library function scanf is used to take the three values and stored them in variables. Then according to the simple interest formula, these three values are multiplied together and divide that value by 100, and store result in the variable 'si';


STEP 1: Import the Header Libraries to use the built-in functions in the C program such as stdio.h and conio.h

STEP 2: Use the main() function to start the execution of the C program.

STEP 3: Initialize some variable for the principal amount, simple interest, rate of interest, and number of years,

STEP 4: Accept the values from the user for the principal amount, rate of interest, and number of years using printf and scanf built-in functions in stdio.h library. We use the float datatype with some precision.

STEP 5: Calculate the simple interest using the formula p*n*r/100.

STEP 6: With help of the printf function and float datatype with some precision we print the values of p. n, r, and the simple interest using C program syntax.

C Source Code

                                          #include <stdio.h>

void main() {

  float p, r, si;
  int t;
  printf("Enter the values of p,r and t\n");
  scanf("%f %f %d", & p, & r, & t);
  si = (p * r * t) / 100.0;
  printf("Amount = Rs. %5.2f", p);
  printf("Rate   = Rs. %5.2f\n", r);
  printf("Time   = %d years\n", t);
  printf("Simple interest  = %5.2f\n", si);



Enter the values of p,r, and t

Amount = Rs. 2000.00
Rate   = Rs.  8.00%
Time   = 3 years
Simple interest  = 480.00