I keep getting the wrong result for multiplication, it only compounds with more iterations, but at one it returns 500 instead of 495.
I have tried initializing the variable and flipping the terms but it is not helping.
void output_short_format(double loan_amount, double interest_rate, double term_years){
double payment,interest=0,total,months,temp;
temp = loan_amount;
interest_rate /= 12;
months = 12 * term_years;
payment = loan_amount * interest_rate * (pow(1+interest_rate,months)/(pow(1+interest_rate,months)-1));
for(int i=1;i<=months;i++){
interest += temp*interest_rate;
temp -= payment;
}
I expect 150000 * 0.0033 to produce 495 not 500