Write a Ruby program to check two non-negative integer values and return true if they have the same last digit.
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
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: