C Program to Find Simple Interest

This C program calculates the simple interest based on the principal amount, interest rate, and time period. It applies the formula: simple_interest = (principal * rate * time) / 100 and provides the resulting value.

In finance, interest refers to the cost of borrowing money or the return on investment when lending money. Simple interest is a straightforward method used to calculate interest on a loan or investment, based on the principal amount, the interest rate, and the time period involved.

Program Statement

Write a C program to calculate the simple interest based on the principle amount, rate of interest, and time period provided by the user. Display the calculated simple interest as the output.

The program should perform the following steps:

  1. Prompt the user to enter the principle amount.
  2. Read and store the principle amount.
  3. Prompt the user to enter the rate of interest.
  4. Read and store the rate of interest.
  5. Prompt the user to enter the time period in years.
  6. Read and store the time period.
  7. Calculate the simple interest using the formula: (principle * rate * time) / 100.
  8. Display the calculated simple interest on the screen.

C Program to Find Simple Interest

#include <stdio.h>

int main() {
    float principal, rate, time, interest;

    // Input the principal amount, rate of interest, and time
    printf("Enter the principal amount: ");
    scanf("%f", &principal);
    
    printf("Enter the rate of interest (in percentage): ");
    scanf("%f", &rate);
    
    printf("Enter the time period (in years): ");
    scanf("%f", &time);

    // Calculate the simple interest
    interest = (principal * rate * time) / 100;

    // Print the simple interest
    printf("Simple Interest = %.2f\n", interest);

    return 0;
}

How it works?

  1. The program starts by including the necessary header file, stdio.h, which provides input and output functions.
  2. Inside the main() function, the program declares the necessary variables: principle, rate, time, and interest, all of which are of type float.
  3. The program prompts the user to enter the principle amount using printf().
  4. The scanf() function is used to read and store the principle amount entered by the user in the variable principle.
  5. The program then prompts the user to enter the rate of interest.
  6. The scanf() function is used again to read and store the rate of interest entered by the user in the variable rate.
  7. Next, the program prompts the user to enter the time period in years.
  8. The scanf() function is used once more to read and store the time period entered by the user in the variable time.
  9. The program calculates the simple interest using the formula (principle * rate * time) / 100 and stores the result in the variable interest.
  10. Finally, the program uses printf() to display the calculated simple interest on the screen, with the value being rounded to two decimal places using the %.2f format specifier.
  11. The program ends with the return 0; statement, indicating successful execution.

By following these steps, the program takes user inputs for the principle amount, rate of interest, and time period, calculates the simple interest using the provided formula, and displays the result.

Input/Output

Share:

Leave A Reply

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

You May Also Like

This C program calculates the volume and surface area of a sphere using its radius. A sphere is a three-dimensional...
This C program converts a Roman numeral to a decimal number. Roman numerals are a system of numerical notation used...
This C program calculates the value of sin(x) using the Taylor series expansion. The Taylor series expansion is a mathematical...