
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
EMI Calculator Program in C
Given with certain values the program will develop an EMI calculator to generate the needed output. EMI stands for Equated Monthly Installment. So this calculator will generate monthly EMI amount for the user.
Example
Input-: principal = 2000 rate = 5 time = 4 Output-: Monthly EMI is= 46.058037
The formula used in the below program is −
EMI : (P*R*(1+R)T)/(((1+R)T)-1)
where,
P indicates loan amount or the Principal amount.
R indicates interest rate per month
T indicates loan time period in year
Approach used below is as follows
- Input principal, rate of interest and time in float variable
- Apply the formula to calculate the EMI amount
- Print the EMI amount
Algorithm
Start Step 1 -> Declare function to calculate EMI float calculate_EMI(float p, float r, float t) float emi set r = r / (12 * 100) Set t = t * 12 Set emi = (p * r * pow(1 + r, t)) / (pow(1 + r, t) - 1) Return emi Step 2 -> In main() Declare variable as float principal, rate, time, emi Set principal = 2000, rate = 5, time = 4 Set emi = calculate_EMI(principal, rate, time) Print emi Stop
Example
#include <math.h> #include <stdio.h> // Function to calculate EMI float calculate_EMI(float p, float r, float t){ float emi; r = r / (12 * 100); // one month interest t = t * 12; // one month period emi = (p * r * pow(1 + r, t)) / (pow(1 + r, t) - 1); return (emi); } int main(){ float principal, rate, time, emi; principal = 2000; rate = 5; time = 4; emi = calculate_EMI(principal, rate, time); printf("
Monthly EMI is= %f
", emi); return 0; }
Output
Monthly EMI is= 46.058037
Advertisements