Task

Compute the sum and product of an array of integers.




DEFINE LAST="6"
 
PROC Main()
  INT ARRAY data=[1 2 3 4 5 6 7]
  BYTE i
  INT a,res
 
  res=0
  FOR i=0 TO LAST
  DO
    a=data(i)
    PrintI(a)
    IF i=LAST THEN
      Put('=)
    ELSE
      Put('+)
    FI
    res==+a
  OD
  PrintIE(res)
 
  res=1
  FOR i=0 TO LAST
  DO
    a=data(i)
    PrintI(a)
    IF i=LAST THEN
      Put('=)
    ELSE
      Put('*)
    FI
    res=res*a
  OD
  PrintIE(res)
RETURN