I have to write a program that determines the miles per gallon for
3 tanks of gasoline. The program prompts you to enter the number of gallons used and number of miles driven for each of the 3 tankfuls of gas. The program will then calculate and display the miles per gallon obtained for each tankful. I can't figure out how to write the statement to calculate this. Below is what I have. If anyone can help, or give me some idea on where I am wrong, i would appreciate it.
I know the result is wrong....does anyone have an example similar that uses division?Code:/* Variable Declarations */ int x, result, miles_per_gallon; float gallons_used, miles_driven; /* Greeting*/ printf("Welcome to the Acme Mileage Calculator Program\n\n"); printf ("Enter the number of gallons used:"); scanf ("%.1f",&gallons_used); printf("Enter the number of miles driven:"); scanf("%.1f",&miles_driven); for (x = galons_used / miles_driven;) result = x; printf("Miles per gallon for this tank is %i\N",x,result); [edited for code tags by ygfperson]