The concept is to use either a series of inputs and store the largest based on the conditional from a loop, or to use a recursive method to resolve the challenge.
program Hello; var input : Integer; maxX : Integer; begin maxX := -1; REPEAT write ('Enter a value (or -1 to exit) : '); Readln(input); if (input > maxX) then maxX := input; UNTIL (input = -1) WriteLn(maxX); end. |
The above will solve for all positive values, the maxX is storing the largest value until the exit flag is entered. Adjust the exit flag (-1) to an alternative flag value if needed.
There are additional approaches, this is however the simplest.