Write a Ruby program to check two non-negative integer values and return true if they have the same last digit.
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
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:
need an explanation for this answer? contact us directly to get an explanation for this answer