Code: Select all
DIM numbers(5)
numbers(0) = 1 ! numbers(1) = 2
numbers(2) = 3 ! numbers(3) = 4
numbers(4) = 5
DEF average(total, nums())
avg = sumArray(nums(),total)
avg = divide(sum, total)
RETURN avg
END DEF
DEF sumArray(numbers(), elements)
sum = 0
FOR COUNT = 0 TO elements - 1
sum+= numbers(COUNT)
NEXT COUNT
RETURN sum
END DEF
DEF divide(num, divisor)
RETURN num / divisor
END DEF
PRINT average(5, numbers)