begin
integer A, B, SUM, DIFFERENCE, MAX, MIN
MAX = -1; MIN = 5000
cycle
READ(A)
exit if A=-1; ! End of input.
READ(B)
PRINTSTRING("Input values:")
WRITE(A,3); PRINTSYMBOL(',')
WRITE(B,3)
SUM = A+B; DIFFERENCE = A-B
PRINTSTRING(" ... Sum is")
WRITE(SUM,3)
PRINTSTRING(", Difference is")
WRITE(DIFFERENCE,3); NEWLINE
if SUM>MAX start
MAX = SUM
finish else if SUM<MIN start { BUG! <--- a sum betweem initial min and max only assigns max, should assign min as well! }
MIN = SUM
finish
monitor
repeat
! Now print out the maximum and minimum of the sums of all
! the pairs of numbers read in.
NEWLINE
PRINTSTRING("Maximum sum is")
WRITE(MAX,3); NEWLINE
PRINTSTRING("Minimum sum is")
WRITE(MIN,3); NEWLINE
end of program