Ruby Basic Exercises: Print names in reverse order with a space between them
Ruby Basic: Exercise-6 with Solution
Write a Ruby program which accept the user's first and last name and print them in reverse order with a space between them.
Ruby Code:
puts "Input your first name: "
fname = gets.chomp
puts "Input your last name: "
lname = gets.chomp
puts "Hello #{lname} #{fname}"
Output:
Input your first name: Input your last name: Hello Lanoie Gary
Flowchart:
Ruby Code Editor:
Contribute your code and comments through Disqus.
p>Previous: Write a Ruby program to check if a string starts with "if".Next: Write a Ruby program to accept a filename from the user print the extension of that.
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