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 test_last_digit(a, b)
   return (a % 10 == b % 10);
end
print test_last_digit(5, 5),"\n"
print test_last_digit(15, 25),"\n"
print test_last_digit(256, 346),"\n"
print test_last_digit(26, 34)
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