...

/

Solution: Get Character from Alphabetical Position

Solution: Get Character from Alphabetical Position

Go over the implementation of the get alphabet problem from the previous exercise.

Solution

array = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
puts "I know the alphabet very well, enter the alphabetical order number (integer) \nand I \
will tell you the corresponding letter, 0 to quit:"
while true
    input = gets.chomp.to_i 
    if input == 0
        break 
    end
    n = input - 1
    puts array[n] 
end
Get Alphabet from its integer position

Explanation

  • Line 1: We define an array of 26 elements to represent 26 ...