Write a C Program to Find Simple Interest.

Prince Patel
By -
0

Write a C Program to Find Simple Interest.


In this article, we will calculate the simple interest without using structures and functions. Simple interest can be calculated using the formula.

        Simple Interest (SI) = (Principal * Rate * Time) / 100

Where:

Principal: The initial amount of money.
Rate: The rate of interest per annum.
Time: The time period in years.

Here's a C program to Find Simple Interest:

#include<stdio.h>
#include<conio.h>

void main()
{
    // Declare variables to store principal, rate, and time
    float principal, rate, time;
    
    // Read input from the user
    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 simple interest
    float simpleInterest = (principal * rate * time) / 100;
    
    // Display the result
    printf("Simple Interest: %.2f\n", simpleInterest);
}

  • We first declare three variables principal, rate, and time to store the input values. 
  • We then use printf and scanf functions to get these values from the user. 
  • After obtaining the values, we calculate the simple interest using the formula and store it in the variable simpleInterest
  • Finally, we display the result using printf with %.2f to print the result up to two decimal places.
Output:


Tags:

Post a Comment

0Comments

Post a Comment (0)