문제
매월 특정 대출 금액(이자 포함)에 대해 지불해야 하는 잔액 할부를 계산하는 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\n",firstmon); printf("remaining amount need to pay after 2nd installment:%.2f\n",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