#include <stdio.h>
int main(void) {
float interest_rate, amount_of_loan, monthly_payment, remain_payment;
printf("Enter amount of loan :");
scanf("%f", &amount_of_loan);
printf("Enter interest rate :");
scanf("%f", &interest_rate); // this is a interest rate per a year
printf("Monthly interest rate is : %.1f\n" , (interest_rate / 12)); // 퍼센트를 표현하는 방법
((interest_rate / 12) * 0.01); //it would be 0.005
printf("Enter monthly payment : ");
scanf("%f", &monthly_payment);
remain_payment = (amount_of_loan + (amount_of_loan * ((interest_rate / 12) * 0.01))) - monthly_payment;
printf("Balance remaining after first payment : %.2f\n", remain_payment);
// 0.005 is interest value and the payment is 386.66
remain_payment = (remain_payment + (amount_of_loan * ((interest_rate / 12) * 0.01))) - monthly_payment;
printf("Balance remaining after second payment :%.2f\n", remain_payment);
remain_payment = (remain_payment + (amount_of_loan * ((interest_rate / 12) * 0.01))) - monthly_payment;
printf("Balance remaining after third payment :%.2f\n", remain_payment);
return 0;
}
Do I have to use round down function with floor
function?
I searched about round up and down function in <math.h>
file but I couldn't get exact result I think I know why I couldn't get the exact answer, the reason I guess was float type store my input approximately.
But I wanna get exact output that I want