In this article, we are going to learn how to calculate the EMI for a loan amount at a given rate of interest and time period of the loan with example.
C Program to design an EMI calculator
In this example, Here we are calculating the mortgage amount for a given loan amount. We will ask the user to enter the loan amount that they want to borrow. They will also tell how much time period they will hold the amount.
We will take the interest rate also as input. The formula to calculate the EMI amount will be:
(PR(1+R)T)/(((1+R)T)-1)
Where :
- P – Principal Loan amount.
- R – Rate of interest.
- T – Time period.
#include <stdio.h>
#include <math.h>
int main()
{
float LoanAmount;
float InterestRate;
float LoanPeriod;
float MonthlyInstallment;
printf("Please enter the Loan Amount: ");
scanf("%f",&LoanAmount);
printf("Please enter the rate of Interest: ");
scanf("%f",&InterestRate);
printf("Please specify the loan period in Years: ");
scanf("%f",&LoanPeriod);
InterestRate=InterestRate/(12*100);
LoanPeriod=LoanPeriod*12;
MonthlyInstallment= (LoanAmount*InterestRate*pow(1+InterestRate,LoanPeriod))/(pow(1+InterestRate,LoanPeriod)-1);
printf("Your Monthly Payment Installment will be = %f\n",MonthlyInstallment);
return 0;
}
Output
Please enter the rate of Interest: 7
Please specify the loan period in Years: 12
Your Monthly Payment Installment will be = 123.404999