Current location - Loan Platform Complete Network - Loan intermediary - C language question: A customer applied for a commercial loan to purchase a house and chose the equal monthly principal and interest repayment method. The calculation formula is as follows? In the loa
C language question: A customer applied for a commercial loan to purchase a house and chose the equal monthly principal and interest repayment method. The calculation formula is as follows? In the loa
C language question: A customer applied for a commercial loan to purchase a house and chose the equal monthly principal and interest repayment method. The calculation formula is as follows? In the loan principal (loan

#include?

float?cal_power(float?x,?int?n)

{

float?p=1.0;

while(n>0)?{

p=p*x;

n--;

< p>}

return?p;

}

float?cal_money(int?loan,?float?rate,?int?month)

{

double?tmp;

tmp=cal_power(1+rate,month);

return?loan*rate*tmp/( tmp-1);

}

int?main(void)

{

int?loan,year,month;< /p>

float?money,rate;

printf("Enter?loan:?");

scanf("%d",&loan);

printf("Enter?rate:?");

scanf("%f",&rate);

for(year=5;year<=30; year++)?{

month=12*year;

money=cal_money(loan,rate,month);

printf("money(%d, %d)=%.0f\n",loan,year,money);

}

return?0;

}