Write a Ruby program to check a given non-negative number and return true if number is within 2 of a multiple of 10.
def check_num(num) return num % 10 <= 2 || num % 10 >= 8; end print check_num(9),"\n" print check_num(13),"\n" print check_num(22),"\n" print check_num(-12),"\n" print check_num(0)
Output:
true false true true true
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