I have some basic question regarding some C program
that I have made just for fun (I am trying to teach
myself C)
Please have a look at the program below:
If you compile it then the error will be self
apparent, the first time it calculates the MPG it
returns zero, the second mpg calculation is actually
for the first one and so on :).
#include <stdio.h>
/*Main program body*/
void main(void)
{
float gallons, miles, mpg;
int counter;
for (counter=1; counter <=3; counter++)
{
mpg = miles / gallons;
if (counter == 1)
printf("Enter the number
of gallons used for tank#%i: ", counter);
else
printf("\nEnter the number
of gallons used for tank#%i: ", counter);
scanf("%f", &gallons);
printf("Enter the number of miles
driven: ");
scanf("%f", &miles);
printf("*** The miles per gallon
for this tank is %f", mpg);
}
}
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com