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)
   return ((a + b) == c || (b + c) == a || (c + a) == b)
end

print check_num(9, 12, 21),"\n"
print check_num(0, -5, -5),"\n"
print check_num(-5, 7, 2),"\n"
print check_num(6, 5, 4)
Output:
true
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