Ruby print “Enter the first number: “ FirstNo = gets.chomp.to_i print “Enter the second number: “ SecondNo = gets.chomp.to_i sum = FirstNo + SecondNo puts “The sum of the two numbers is: #{sum}”Step 1: user is will enter two numbers Step 2: two numbers are stored in the variables and variables are FirstNo and SecondNo. Step 3: The to_i method is used to convert the input to an integer because input is initially a string. Step 4: the sum of the two numbers is calculated Step 5: sum of the two numbers is stored in the variable sum. Step 6: The puts method is used to print out the result.
Write a program in ruby to add two numbers
I am sharing with you, a simple program in Ruby to add two numbers: