Ruby Basic Exercises: Find the maximum of two numbers
Ruby Basic: Exercise-18 with Solution
Write a Ruby program to find the maximum of two numbers.
Ruby Code:
x= 6
y =8
max = x>y ? x:y
puts "Max = "+max.to_s
Output:
Max = 8
Flowchart:
Ruby Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a Ruby program to compute the absolute difference between n and 33 and return double the absolute difference if n is over 33.
Next: Write a Ruby program to check two integers and return true if one of them is 20 otherwise return their sum.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- 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
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework