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?
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/ruby-exercises/basic/ruby-basic-exercise-6.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics