Ruby Basic Exercises: Check three given integers and return true if two or more of them have the same rightmost digit
Ruby Basic: Exercise-48 with Solution
Write a Ruby program to check three given integers and return true if two or more of them have the same rightmost 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)
true true false
Ruby Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a Ruby program to check three given integers and return true if it is possible to add two of the integers to get the third.
Next: Write a Ruby program to check three given integers and return true if one of them is 20 or more less than one of the others.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework