Ruby Basic Exercises: Check three given integers and return true if two or more of them have the same rightmost digit
Write a Ruby program to check three given integers and return true if two or more of them have the same rightmost digit.
Ruby Code:
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
Flowchart:

Go to:
PREV : Write a Ruby program to check three given integers and return true if it is possible to add two of the integers to get the third.
NEXT : Write a Ruby program to check three given integers and return true if one of them is 20 or more less than one of the others.
Ruby Code Editor:
Contribute your code and comments through Disqus.
What is the difficulty level of this exercise?