Ruby program to find length of a string

Views: 123   

Following program shows you how to find length of a string.
In this program we get string from user and prints the length using .length

puts "Please enter the string:"
input = gets.to_s.strip
lengthOfString = input.length
puts "Length of the given string is: #{lengthOfString}"

Output:

Please enter the string:
hello
Length of the given string is: 5
On By