Q:

Write a Ruby program to check whether a given array of integers of length 2 does not contain a 6 or a 9

0

 Write a Ruby program to check whether a given array of integers of length 2 does not contain a 6 or a 9.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def check_array(nums)
   if(nums[0] == 6 || nums[0] == 9)
		return false
	end
	return !(nums[1] == 6 || nums[1] == 9)
end

print check_array([1, 4]),"\n" 
print check_array([6, 5]),"\n"   
print check_array([5, 9])  

Output:

true
false
false

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now