I won't bore you with details, but this program I've been working on crashes every time, right after I enter the value for the first variable and I don't have a clue why. Any ideas?
-----
/* This program calculates and displays a car's mpg for an indefinite number of tankfulls, then calculates and displays the average mpg. */
#include <stdio.h>
int main()
{
float gal, mil, mpg;
int sum = 0, count = 0;
printf( "Enter the gallons used (-1 to end): ");
scanf( "%f", gal );
while ( x != -1 )
{
printf( "Enter the miles driven: " );
scanf( "%f", mil );
mpg = mil / x;
printf( "The mpg for this tank was %f", mpg);
sum += mpg;
++count;
printf( "Enter the gallons used (-1 to end): ");
scanf( "%f", gal );
}
printf( "The overall average mpg was %f", sum / count );
return 0;
}
-----------
Thanks.
Ash