Back to table

!£$%^*$&-- The Average --$£$%^&$

The following is a valid µOCCAM program that performs I/O. This is a very basic program demonstrating program I/O. The program takes 3 integer inputs and outputs the average of the 3.

Program file: /public/cs3/web/ipptests/average.io

-- Calculate Average Program

INT a :
INT b :
INT c :
INT average :

SEQ
  stdin ? a
  stdin ? b
  stdin ? c

  PAR
    a := a + b
    a := a + c

  average := a / 3
  stdout ! average

When provided with this input: /public/cs3/web/ipptests/average.in

1
2
3

it should generate the following output: /public/cs3/web/ipptests/average.out

==> 2