Creating a program in C to calculate simple interests is a fundamental exercise for beginners and intermediate programmers. This tutorial will guide you through the process, including examples and explanations, to help you understand and build this practical program.

## What is Simple Interest?

Simple interest is a way of calculating the interest on a loan or investment. It is calculated by multiplying the principal amount (the initial amount borrowed or invested) by the interest rate and the time period. This is a standard method for short-term loans and investments.

## Algorithm to Calculate Simple Interest

**Initialize Variables:**Declare variables to store the principal amount (P), interest rate (R), time period (T), and simple interest (SI).**Input Values:**Prompt the user to enter the principal amount, interest rate, and time period. Use the`scanf()`

function to take input from the user.**Calculate Interest:**Apply the simple interest formula:`SI = (P * R * T) / 100`

. This formula calculates the simple interest based on the provided principal amount, interest rate, and time period.**Output Result:**Display the calculated simple interest using the`printf()`

function. Format the output using`%.2f`

to display two decimal places.

## Code Example

Here's a C program that calculates simple interest using the above algorithm:

```
#include <stdio.h>
int main() {
float principal, rate, time, interest;
// Take user input for principal, rate, and time
printf("Enter principal amount: ");
scanf("%f", &principal);
printf("Enter interest rate: ");
scanf("%f", &rate);
printf("Enter time period (in years): ");
scanf("%f", &time);
// Calculate simple interest
interest = (principal * rate * time) / 100;
// Display the result
printf("Simple Interest is: %.2f\n", interest);
return 0;
}
```

Program Output:

For example, if you input a principal amount of `1000`

, an interest rate of `6%`

, and a time period of `2`

years, the program will calculate and display the simple interest as `120.00`

.

```
Enter principal amount: 1000
Enter interest rate: 6
Enter time period (in years): 2
Simple Interest is: 120.00
```

## Conclusion

Writing a C program to calculate simple interest is a straightforward process. By understanding the concept of simple interest and following the provided algorithm, you can easily create a program to perform these calculations.