This program is just supposed to ask the user 3 questions and get a calculation of the miles per gallon over and over until the user types a negative number. I have 2 problems currently, first the miles per gallon comes out to be some odd number (ex. 15000 initial miles, 15250 final miles, 10 gallons, should be 25 miles per gallon but it comes out to be 1254792).

Second its supposed to ask all 3 questions again after it calculates the miles per gallon...but instead it just start off asking the 2nd question after it gives the weird calculation. Any idea what I'm doing wrong?

Code:#include <stdio.h> int main() { int input_value, final, gallons, milespergallon; printf("What is your initial odometer reading:\n"); scanf("%d", &input_value); while ( input_value > 0 ) { printf("What is your final odometer reading:\n"); scanf("%d", &final); printf("What is the number of gallons of gas:\n"); scanf("%d", &gallons); milespergallon = ( final - input_value ) / gallons; printf("Miles per gallon: %d, &milespergallon"); } return 0; }

-James

[edit]Code tags added by Hammer.