Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Simple interest is a quickest method of calculating the interest on loan. Here, we'll explore how to calculate a simple interest program in c.
Interest is the extra amount paid over the principal amount when we borrow money. In this article titled “Simple Interest Program in C”, we will discuss the logic and algorithm behind the simple interest program in c.
Simple Interest Formula
The formula for calculating simple interest (SI) is:
Simple Interest = (P * R * T) / 100
where:
P is the principal amount (initial amount of money).
R is the rate of interest per year (as a percentage).
T is the time duration for which the money is borrowed or invested (in years).
This formula gives the amount of interest earned or paid on the principal amount over a specified time period, assuming the interest is calculated based on the original principal only.
Basic Terminology
Before looking at how to write a simple interest program in c, let’s discuss some terminology related to simple interest.
Principal amount: It is the amount that the borrower had originally borrowed.
Interest: It is the percentage of the principal amount charged extra. An Interest rate is set before lending the principal amount.
Time: It is the duration for which money is lent.
How is simple interest calculated?
Let’s say P is the principal amount, R is the interest rate, and T is the time for which money is lent. Then the interest will be calculated using the following formula:
Simple Interest = (P * R * T) / 100
We multiply the principal amount by the interest rate and time to calculate the interest.
Example
Ques. Calculate the simple interest on a loan amount of Rs. 4016.25 at 9% per annum in 5 years. Find the total amount of money the borrower had to pay.
Ans. The total amount of money the borrower had to pay = Principal amount + Interest on Principal amount.
Total money to pay back = 4016.25 + 1807.3125 = Rs 5823.5625 ~ Rs 5823.6
Algorithm to Calculate Simple Interest Program in C
We can make a simple interest program in c using the following steps:
First, store the principal amount (P), rate of interest ®, and time(T) in the appropriate data type. Generally, all these values can be stored in double data type because their domain includes decimal values.
Calculate Interest using the formula I = (P x R x T) / 100. Interest can also be stored in double data type.
The calculated value can be printed or used in the program.
C Program to calculate simple interest
Code
C
C
// Simple Interest Program in C #include <stdio.h>
int main() {
double P = 20000.0; // principal amount double R = 7.5; // 7.5 % interest rate double T = 4; // For 4 years
double interest = ( P * R * T ) / 100 ; printf("interest is %0.2f ", interest);
We will first declare three variables, P, R and T. These variable stores principal amount, interest rate and time for lending, respectively.
Then, interest is calculated using the formula Interest = (P*R*T)/100.
The interest is printed using the printf function. “%0.2f” denotes that we are printing a float/decimal value and need numbers only up to two decimal places.
Time and Space Complexity
Simple Interest program in c only requires assignment and multiplication operations. These operations require constant time, and also they are constant in number. Hence, the time complexity is O(1).
Similarly, we only need a constant no. of variables and hence space complexity is also O(1).
A simple interest model is a financial calculation method where interest is earned or paid only on the initial principal amount without considering reinvestment or compounding.
What is principal in simple interest?
The principal in simple interest is the initial amount of money deposited or borrowed on which interest is calculated, without considering additional contributions or compounding.
Where is simple interest used?
Simple interest is used in finance to calculate interest on a principal amount, often for loans, savings accounts, or investments, where interest accrues linearly over time.
How do we calculate compound interest?
The compound interest formula is A = P ( 1 + r / n )nt.
Here A is the total amount after interest, P is the principal amount, r is the interest rate, n is the number of times interest gets compounded during the time period, and t is the number of periods money is invested.
How compound interest rate is different from simple interest?
We calculate simple interest on the principal or loan amount, whereas compound interest is calculated on the sum of interest accumulated and the principal amount.
Conclusion
Money lending and Interest is an old phenomenon in human history. We can calculate simple interest using the formula I = (P*R*T)/100. When programming in c, we must store variables in the appropriate data type, i.e. double. The time and space complexity of the simple interest program in c is O(1).
Click here to learn more about Simple and Compound Interests.