Question: write a Lua function called, max_min, that returns the maximum, minimum values stored in an array along with their corresponding index locations. Your function should
write a Lua function called, max_min, that returns the maximum, minimum values stored in an array along with their corresponding index locations. Your function should return the computed values as four seperate return values and include the code given below. function max_min(list,numElems) -- add code return maxVal, maxInd, minVal, minInd end myList = {14,84,202,314,4,5,10,100,114,202} numElems = 10 maxVal. maxInd, minVal, minInd = max_min(myList, numElems) --{prints with format as shown below} maximum value is 314 at postion 4 mininum value is 4 at postion 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
