In this C programming tutorial, we will learn how to calculate simple interest using user-provided inputs. Simple interest is a fundamental concept in finance and is widely used in various financial transactions. It allows us to determine the interest earned or paid on a principal amount over a specific time period.
Formula to calculate Simple Interest.
Simple Interest (SI) can be calculated using the formula:
SI = (P * R * T) / 100
Where:
- SI is the Simple Interest.
- P is the Principal Amount (initial amount invested or borrowed).
- R is the Rate of Interest per period (usually expressed as a percentage).
- T is the Time Duration in years.
Example:
Example: P = 5000 R = 6 T = 3 Explanation: SI = (P * R * T) / 100 = (5000 * 6 * 3) / 100 = (90,000) / 100 = 900
Step-by-step Algorithm.
Step 1: Input the principal amount (P), which is the initial amount invested or borrowed.
Step 2: Input the rate of interest per period (R), usually expressed as a percentage.
Step 3: Input the time duration in years (T) for which the amount is invested or borrowed.
Step 3: Calculate the simple interest (SI) using the formula: SI = (P * R * T) / 100
Step 4: Display the calculated simple interest.
C code to find Simple Interest.
//C program to find simple interest #include <stdio.h> int main() { float principal, rate, time, simpleInterest; printf("Enter the principal amount: "); scanf("%f", &principal); printf("Enter the rate of interest per period: "); scanf("%f", &rate); printf("Enter the time duration in years: "); scanf("%f", &time); // Calculate the simple interest simpleInterest = (principal * rate * time) / 100; printf("Simple Interest: %.2f\n", simpleInterest); return 0; }
Enter the principal amount: 6000
Enter the rate of interest per period: 5
Enter the time duration in years: 6
Simple Interest: 1800.00
Time Complexity: O(1)
Space Complexity: O(1)
No comments:
Post a Comment