I'm writing a program that takes the length and width of a rectangular yard and house then computes the time required to cut the grass at two square feet a second. The final output my program gives is "NaN". Does anyone have any advice how I could write this better and produce better results? Thanks in advance. Here is what I have so far:
Code:
/*
Filename: mow.c
Description: Compute the required time to cut grass at two square
feet a second.
*/
#include <stdio.h>
#include <math.h>
int main()
{
/* memory allocation for data */
double ylength,ywidth,hlength,hwidth,yarea,harea,grasqyd,grasqft,time;
/* prompt user for data */
printf ("Enter the length of the yard in feet (eg.20):";
scanf ("%lf",& ylength);
printf ("Enter the width of the yard in feet (eg.20):");
scanf ("%lf",& ywidth);
printf ("Enter the length of the house in feet (eg.20):");
scanf ("%d",& hlength);
printf ("Enter the width of the house in feet (eg.20):");
scanf ("%lf",& hwidth);
/* compute the total area of grass */
yarea = ylength * ywidth;
harea = hlength * hwidth;
grasqyd = yarea - harea;
grasqft = grasqyd * 9;
/* compute the time required */
time = grasqft/2;
/* display result */
printf
("The time required to cut the grass at a rate of two square feet a\n"
"second is %f \n",time);
/* End */
return 0;
}