var
numToPrint: Integer;
x, y : integer;
procedure printNum;
begin
writeln(numToPrint)
end;
begin
readln(x,y);
numToPrint := x + y;
printNum;
numToPrint := x - y;
printNum
end.
This program clumsily utilize subroutine printNum to print the sum and difference of x and y. Note how the value to be printed must be assigned to the global variable numToPrint first?
In the next chapter, we'll discuss better methods to pass information into and out of subroutines.