Two Functions Calling The Same Array
Posted: Mon Nov 02, 2015 3:12 am
				
				Can someone tell me how to get this code to work? I am passing in an array and then trying to pass the array into another function that is called within the same function.
			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)