Write a Ruby program to get the number of even integers in a given array.
def check_array(nums) count = 0 nums.each do |item| if((item % 2) == 0) count=count + 1 end end return count end print check_array([3, 4, 5, 6]),"\n" print check_array([3, 4, 5]),"\n" print check_array([3, 4])
Output:
2 1 1
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