Ok so i have know idea why every time i try to print the results of this
equation came up with to calculate a loans total cost.
This code right here
Code:
float getloanamount(float payment,float months,float yearlyrate)
{
float loanamount;
float i = (yearlyrate/1200);
loanamount = payment*months*100/(i/100)/100;// Equation
printf("test");
return loanamount;
}
Always comes up with 0.000000 no matter what i type in. If anyone knows what the heck is going on here and how i can fix it please do say so.
B.T.W I am using this code to take in the necessary parameters and then print them out.
Code:
{
int numberofpayments;
float yearlyrate ;
float sizeofpayment = 0.0;
float loansize ;
printf("Please enter in the number of yearly payments:");
scanf("%i",&numberofpayments);
putchar('\n');
printf("Number of payments:%i\n",numberofpayments);
printf("Please enter in the yearly rate(interest) of the loan:");
scanf("%f",&yearlyrate);
putchar('\n');
printf("Yearly rate:%f\n",yearlyrate);
printf("Please enter in the loan size:");
scanf("%f",&loansize);
roundtopennies(&loansize);
putchar('\n');
printf("Loan size:%f\n",loansize);
sizeofpayment = getloanamount(sizeofpayment,numberofpayments,yearlyrate);
printf("The loan's size is:%f\n",sizeofpayment);
}