#include <stdio.h>
int main()
{
float gallons;
float miles;
float mileage;
float totalmiles = 0;
float totalgallons = 0;
printf("Enter the gallons used (-1 to end): ");
scanf("%f", &gallons);
while (gallons != -1)
{
printf("Enter the miles driven: ");
scanf("%f", &miles);
mileage = miles / gallons;
printf("The miles/gallon for this tank was %f\n\n", mileage);
totalmiles = totalmiles + miles;
totalgallons = totalgallons + gallons;
printf("Enter the gallons used (-1 to end): ");
scanf("%f", &gallons);
}
printf("\nThe overall average miles/gallon was %f\n", (totalmiles/totalgallons));
return 0;
}