Q:

Write a Ruby program to check two non-negative integer values and return true if they have the same last digit

0

Write a Ruby program to check two non-negative integer values and return true if they have the same last digit.

All Answers

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

def check_num(a, b, c)
    x = a % 10
	y = b % 10
	z = c % 10
	if(x == y)
		return true
	end	
	if(x == z)
		return true
	end
	return (y == z)
end
print check_num(9, 12, 22),"\n"
print check_num(112, 202, 52),"\n"
print check_num(102, 203, 405)
Output:
true
true
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