The Tower of Babel

Average Milles Per Gallon Algorithm in Pascal

1  program Miles_Per_Gallon(input, output);
2  var { variable declarations }
3     starting_mileage, ending_mileage, distance_driven : integer;
4     gallons_used,average_miles_per_gallon : real;
5  begin { Pascal implementation }
6    readln(gallons_used, starting_mileage, ending_mileage);
7    distance_driven := ending_mileage - starting_mileage;
8    average_miles_per_gallons := distance_driven / gallons_used;
9    writeln(average_miles_per_gallon)
10 end.

 
[TOC][Next]

CS1104 Main Page
Last Updated 01/05/2000
© L.Heath, 2000