Task

Create a function that returns the maximum value in a provided set of values,

where the number of values may not be known until run-time.




BYTE FUNC Max(BYTE ARRAY tab BYTE size)
  BYTE i,res
 
  res=tab(0)
  FOR i=1 TO size-1
  DO 
    IF res<tab(i) THEN
      res=tab(i)
    FI
  OD
RETURN (res)
 
PROC Main()
  BYTE i,m,size=[20]
  BYTE ARRAY tab(size)
 
  FOR i=0 TO size-1
  DO 
    tab(i)=Rand(0)
  OD
 
  Print("Array:")
  FOR i=0 TO size-1
  DO
    PrintF(" %I",tab(i))
  OD
  PutE()
 
  m=Max(tab,size)
  PrintF("Greatest: %I%E",m)
RETURN