Write a Ruby program to compute the sum of all the elements. The array length must be 3 or more.
def check_array(nums) return (nums[0] + nums[1] + nums[2]) end print check_array([1, 2, 5]),"\n" print check_array([1, 2, 3]),"\n" print check_array([1, 2, 4])
Output:
8 6 7
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer