Ruby Basic Exercises: Check two integer values with in a range
Ruby Basic: Exercise-9 with Solution
Write a Ruby program to check three numbers and return true if one or more of them are small. A number is called "small" if it is in the range 1..10 inclusive.
def in110(a, b, c) return ((a >= 1 && a <= 10) || (b >= 1 && b <= 10) || (c >= 1 && c <= 10)); end print in110(1, 12, 25),"\n" print in110(10, 15, 33),"\n" print in110(11, 25, 43),"\n"
true true false
Ruby Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a Ruby program to check two integer values whether either of them is in the range 20..30 inclusive.
Next: Write a Ruby program to check three numbers and return true if one or the other is small, but not both. A number is called "small" if it is in the range 1..10 inclusive.
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