(* Teresa Tong F. 4AS [30] *)
(* To read a list of positive numbers and determine
the difference between the largest and smallest *)
program large_small;
uses wincrt;
var max, min, n, diff : real;
begin
write('Enter numbers (0 to stop)');
readln(N);
max:=n;
min:=n;
while N<>0 do
begin
if n > max
then max:= n
else
if n < min
then min:= n ;
write('Enter numbers (0 to stop)');
readln(N)
end;
writeln;
writeln('Largest = ', max:8:2);
writeln('Smallest = ', min:8:2);
diff:= Max - Min;
writeln('Difference = ', diff:6:2)
end.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
e.g.
1) Enter the numbers (0 to stop) 5
Enter the numbers (0 to stop) 99
Enter the numbers (0 to stop) 30
Enter the numbers (0 to stop) 0
Largest = 99.00
Smallest = 5.00
Difference = 94.00
2) Enter the numbers (0 to stop) 5555
Enter the numbers (0 to stop) 850
Enter the numbers (0 to stop) 628
Enter the numbers (0 to stop) 3469
Enter the numbers (0 to stop) 0
Largest = 5555.00
Smallest = 628.00
Difference = 4927.00
               (
geocities.com/ttt_7_ttt)