Plain and simply- as pointed out by Lurk & Aalmaron- you forgot to read in the values for the variables in your loop i.e. cin>>gallons; and the other. Always make sure you can reach the exit conditon you set for a loop.