Write a Ruby program to check whether a given array of integers of length 2 contains a 4 or a 7.
def check_array(nums) if(nums[0] == 4 || nums[0] == 7) return true end return (nums[1] == 4 || nums[1] == 7) end print check_array([1, 4]),"\n" print check_array([7, 5]),"\n" print check_array([5, 2])
Output:
true true false
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