Write a Simple Interest Program in C using the SI formula.

**Simple Interest** is the amount of money that a borrower pays to a lender as a percentage of the principal amount borrowed.

Common terms in the calculation of Simple interest:

**Principal:**The amount of money borrowed.**Period:**he period of time for which the money is borrowed.**Rate of interest:**The percentage of the principal amount that is paid as interest.

Simple Interest = (P × R × T)/100

Here, **P** = Principal Amount, **R** = Rate of Interest and **T** = Time.

**Example:**

Find the Simple Interest on ₹7000 for 2 years at 50% per annum.

**Solution:**

Given, P = 7000, R = 50 and T = 2.

**Simple Interest (SI) = (P * R * T)/100**

SI = (7000 * 50 * 2)/100

SI = 700000/100

SI = 7000

Therefore, the simple interest on ₹7000 at 50% per annum for 2 years is ₹7000.

**Amount** = Principal + Simple Interest = 7000 + 7000 = 14000.

**Algorithm**

1. Enter the principal amount, rate of interest, and time period.

2. Calculate the simple interest using the formula **SI = (P * R * T)/100**.

3. Print the Simple Interest.

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

/* * C program to find the simple interest */ #include<stdio.h> int main() { float principal, rate, time; // Get user input printf("Enter the principal amount: "); scanf("%f",&principal); printf("Enter the rate of interest: "); scanf("%f",&rate); printf("Enter the time: "); scanf("%f",&time); float simple_interest, amount; // Calculate simple interest and amount simple_interest = ((principal*rate*time)/100); amount = simple_interest + principal; // Print the output printf("Simple Interest = %f \nAmount = %f",simple_interest, amount); return 0; }

1. Declare variables to store the values of the principal amount, rate of interest, time period, simple interest, and amount.

2. Get user input for the principal amount, rate of interest, and time period using the **scanf()** function in C and calculate the simple interest using the formula

**simple_interest = ((principal*rate*time)/100);**

3. Calculate the amount using the formula **amount = principal + simple_interest** and store the value in the variable **amount**.

4. Print the amount and simple interest using the standard **printf()** functions.

**Time complexity: O(1)**

The time complexity of the simple interest program is O(1), since it only performs a constant number of operations, regardless of the size of the input.

**Space complexity: O(1)**

The space complexity of the simple interest program is also O(1), since it only requires a constant amount of memory to store the input variables and the output results.

**Testcase 1:** In this case, enter P=7000, R=50, and T=2 as the parameters to calculate simple interest.

Enter the principal amount: 7000 Enter the rate of interest: 50 Enter the time: 2 Simple Interest = 7000.000000 Amount = 14000.000000

**Testcase 2:** In this case, enter P=4000, R=20, and T=3 as the parameters to calculate simple interest.

Enter the principal amount: 4000 Enter the rate of interest: 20 Enter the time: 3 Simple Interest = 2400.000000 Amount = 6400.000000

To practice programs on every topic in C, please visit “Programming Examples in C”, “Data Structures in C” and “Algorithms in C”.

**Related Posts:**

- Practice BCA MCQs
- Check Computer Science Books
- Apply for Computer Science Internship
- Check C Books
- Apply for C Internship