Some points (marked by !!) for you to think about.
Code:
#include <stdio.h>
#include <math.h>/*!! missing, needed for pow*/
int/*!!not void*/ main()
{
int value,deposit;
float years,term,apr,rate,month;
double total,step,permonth,mort,paypermonth,payperyear,balance;
char statement;
printf("Please enter the value of the property \n\r"); /*!! \r is not needed */
scanf("%d",&value);
printf("Please enter the Term (in months) of the mortgage \n\r");
scanf("%f",&term);
printf("Please enter your initial payment (deposit) \n\r");
scanf("%d",&deposit);
printf("Please enter the interest rate (APR) \n\r");
scanf("%f",&apr);
years=term/12;
printf("Years %.1f \n\r",years);
rate=apr/100;
mort=value-deposit;
printf("The amount to be mortgaged is %.2f \n\r",mort);
rate++;
step=pow(rate,years);
total=step*mort;
printf("The total amount payable is %.2f \n\r",total);
permonth=total/term;
printf("The minimum amount you need to pay each month is %.2f \n\n\r",permonth);
/*keep a running count of payments and subtract that value from total amount to pay*/
printf("Do you require a Monthly or Annual statement? (M or A) \n\r");
/*!! another scanf victim */
while ( getchar() != '\n' );
scanf("%c",&statement);
if(statement==/*!! ==, not =*/'A')
{
printf("Annual Mortgage Statement: \n\n\r");
/*!! month <= years makes no sense */
for (month=1;month<=years;month++)
{
payperyear=permonth*12;
/*!! this for loop has no exit condition */
/*!! also, do you even need a loop here for annual payments? */
for (balance=total;;balance=balance-payperyear)
{
printf("Year %.0f Payments of %.2f Balance %.2f \n\r",
month,payperyear,balance);
}
}
}
if(statement==/*!! ==, not =*/'M')
{
printf("Monthly Mortgage Statement: \n\n\r");
for (month=1;month<=years;month++)
{
for (paypermonth=1;paypermonth<13;paypermonth++)
/*!! foo.c:51: warning: too few arguments for format */
/*!! meaning you have more % conversions than parameters */
printf("Year %.0f Month %.0f Payment %.2f Balance %.2f\n\r",
month,paypermonth,permonth);
}
}
return 0;/*!! missing */
}