Reversing a string We can print the reverse a given number by below ways By .reverse predefined method puts "Enter the String:" puts "The reverse of #{str1} is #{str1.reverse}" Output Enter the String: By loop puts "Enter the String:" newstr= ' ' for i in 1..str1.length puts "The reverse of #{str1} is #{newstr}" Output Enter the String:
str1=gets.chomp
ruby
The reverse of ruby is ybur
str1=gets.chomp
newstr+=str1[str1.length - i]
end
ruby
The reverse of ruby is ybur
How to Sort Array in Ruby?
how to create an array with Array.[](*args) in Ruby ?
Ruby program to add two integer numbers
Program to Print Triangle of Numbers in Ruby
Ruby program to reverse a string
Ruby program to print Fibonacci series
Ruby program to check whether the given number is Armstrong
What are some of your favorite gems? What are their alternatives?
How to Get Input with Gets in Ruby
How to Replace array elements in Ruby?
Ruby program to check whether the given number is palindrome
What are #method_missing and #send? Why are they useful?
Ruby program to generate random numbers
What are the various Ruby runtimes, and how are they different?
Creating Array with Array.new(size, obj) in Ruby
How to get index of array element in Ruby
Ruby program to check whether the given number is prime or not
How to shuffle an array in Ruby?
Ruby program to Calculate the factorial of given number
What's the difference between a lambda, a block and a proc?
How to create two dimensional array in ruby?
How to add/remove elements to Array in Ruby?
Ruby program to print an array