使用 C 程序设计 EMI 计算器
提供给程序以特定值,此程序将开发一个 EMI 计算器以生成所需的输出。EMI 代表等额月供。因此,此计算器将为用户生成每月的 EMI 金额。
示例
Input-: principal = 2000 rate = 5 time = 4 Output-: Monthly EMI is= 46.058037
本程序中使用的公式为:
EMI:(P*R*(1+R)T)/(((1+R)T)-1)
其中:
P 表示贷款金额或本金金额。
R 表示每月利率
T 表示贷款期限,以年为单位
下面使用的方法如下:
- 输入浮点变量中的本金、利率和时间
- 应用公式计算 EMI 金额
- 打印 EMI 金额
算法
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
示例
#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;
}输出
Monthly EMI is= 46.058037
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP