The following is a valid µOCCAM program that performs I/O. The program will take three values and return the maximum value. It makes use of IF statements.
Program file:
/public/cs3/web/ipptests/max.io
-- This program takes three numbers from the standard input -- and outputs the largest of these three numbers INT a: INT b: INT c: INT max: SEQ stdin ? a -- Read in the first number stdin ? b -- Read in the second number stdin ? c -- Read in the third number max := a -- Let the maximum value equal the first number IF b > max max := b-- If the second number is greater than the max value then -- the new max value should be equal to the second number IF c > max max := c-- If the third number is greater than the max value then -- the new max value should be equal to the third number stdout ! max
When provided with this input:
/public/cs3/web/ipptests/max.in
4 2 9
it should generate the following output:
/public/cs3/web/ipptests/max.out
==> 9