编写 C 程序以计算分期付款余额
问题
编写一个 C 程序来计算每月需要支付的余额分期付款,用于特定贷款金额(含利息)。
解决方案
以下是给定贷款金额的利息计算公式 −
i=loanamt * ((interest/100)/12);
以下计算结果含利息金额 −
i=i+loanamt; firstmon=i-monthlypayment; //first month payment with interest i=firstmon * ((interest/100)/12);
程序
#include<stdio.h>
int main(){
float loanamt,interest,monthlypayment;
float i,firstmon,secondmon;
printf("enter the loan amount:");
scanf("%f",&loanamt);
printf("interest rate:");
scanf("%f",&interest);
printf("monthly payment:");
scanf("%f",&monthlypayment);
//interest calculation//
i=loanamt * ((interest/100)/12);
//amount with interest
i=i+loanamt;
firstmon=i-monthlypayment; //first month payment with interest
i=firstmon * ((interest/100)/12);
i=i+firstmon;
secondmon=i-monthlypayment; //second month payment with interest
printf("remaining amount need to pay after 1st installment:%.2f
",firstmon);
printf("remaining amount need to pay after 2nd installment:%.2f
",secondmon);
return 0;
}输出
enter the loan amount:45000 interest rate:7 monthly payment:1000 remaining amount need to pay after 1st installment:44262.50 remaining amount need to pay after 2nd installment:43520.70
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP