Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Program for EMI Calculator in C program
EMI (Equated Monthly Installment) is a fixed payment amount made by a borrower to a lender at a specified date each month. An EMI calculator helps determine the monthly payment amount based on the loan principal, interest rate, and tenure.
Syntax
EMI = (P * R * (1 + R)^T) / (((1 + R)^T) - 1)
Where:
- P − Principal loan amount
- R − Monthly interest rate (annual rate / 12 / 100)
- T − Total number of months (years * 12)
Example: EMI Calculator Implementation
The following program calculates the monthly EMI for a given loan amount, interest rate, and tenure −
#include <stdio.h>
#include <math.h>
/* Function to calculate EMI */
float calculate_EMI(float principal, float rate, float time) {
float monthly_rate, total_months, emi;
/* Convert annual rate to monthly rate */
monthly_rate = rate / (12 * 100);
/* Convert years to months */
total_months = time * 12;
/* Apply EMI formula */
emi = (principal * monthly_rate * pow(1 + monthly_rate, total_months)) /
(pow(1 + monthly_rate, total_months) - 1);
return emi;
}
int main() {
float principal, rate, time, emi;
/* Initialize loan parameters */
principal = 2000; /* Loan amount */
rate = 5; /* Annual interest rate (%) */
time = 4; /* Loan tenure (years) */
/* Calculate EMI */
emi = calculate_EMI(principal, rate, time);
/* Display results */
printf("Loan Amount: %.2f<br>", principal);
printf("Interest Rate: %.2f%% per annum<br>", rate);
printf("Loan Tenure: %.0f years<br>", time);
printf("Monthly EMI: %.2f<br>", emi);
return 0;
}
Loan Amount: 2000.00 Interest Rate: 5.00% per annum Loan Tenure: 4 years Monthly EMI: 46.06
How It Works
- Rate Conversion: Annual interest rate is converted to monthly rate by dividing by 12 and 100
- Time Conversion: Loan tenure in years is converted to months by multiplying by 12
- EMI Calculation: The standard EMI formula uses compound interest to calculate equal monthly payments
- pow() Function: Used to calculate exponential values for compound interest
Key Points
- The
math.hlibrary is required for thepow()function - Interest rate must be converted from annual percentage to monthly decimal
- EMI remains constant throughout the loan tenure
- Higher interest rates or longer tenures result in different EMI amounts
Conclusion
This EMI calculator uses the standard compound interest formula to compute monthly installments. It provides an essential tool for financial planning and loan calculations in C programming.
Advertisements
