This C program takes principal amount, yearly rate, and time as input, then calculates the simple interest and compound interest for the same data and prints them.
Basic Mathematics:
Formula for simple interest:
SI= P x R x T ÷ 100
Where,
SI= Simple Interest ,
P = Principal,
R = Rate of interest,
T = Time period of the Loan/deposit in years.
Formula for compound interest:
A = P(1 + r/n)nt
Where,
A = Accrued Amount (principal + interest)
P = Principal Amount
I = Interest Amount
R = Annual Nominal Interest Rate in percent
r = Annual Nominal Interest Rate as a decimal
r = R/100
t = Time Involved in years, 0.5 years is calculated as 6 months, etc.
n = number of compounding periods per unit t; at the END of each period
Program: Calculate simple and compound interest using C
Output: Calculates and prints simple and compound interest
Enter principal amount: 25000
Enter the yearly rate: 8
Enter the time in years: 3
Simple interest= 6000.00
Compound interest= 6492.80
Ask queries and share your code in the comment section to help others.
Share this article on twitter.
Follow us on twitter.