Code:
#include <stdio.h>
int main ()
{
/*Variable Declarations*/
/*----------------------*/
int quotient, gallused;
float miles_gallons_used,gallons_used;
float miles_driven;
float total_miles=0;
float total_gal=0;
/*Display program info*/
/*--------------------*/
printf ("\nWelcome to my mileage calculator.\n");
printf ("\nThis program will calculate the miles per gallon for you for\n");
printf ("three tanks of gas after you have entered the gallons used and\n");
printf ("miles driven.\n");
/*Prompt user for information*/
/*---------------------------*/
for (gallused = 1; gallused <= 3; ++ gallused )
{
printf ("\nEnter the number of gallons used for tank #%d: ",gallused);
scanf ("%f", &gallons_used);
printf ("Enter the number of miles driven: ");
scanf ("%f", &miles_driven);
miles_gallons_used = miles_driven / gallons_used;
printf ("***The miles per gallon used for this tank is %.1f \n",miles_gallons_used);
total_gal = gallons_used + total_gal;
total_miles = total_miles + miles_driven;
} // end for loop
printf ("\nYour overall average miles per gallon for three tanks is %.1f \n",total_miles /
total_gal);
/*Display End Comment*/
/*---------------*/
printf ("\nThanks for using my mileage calculator program!\n");
} //end main
that works and u get 21.5,so check out what u were doing wrong.