Ruby program to take two numbers from user and add those two numbers
Following program shows you how to take two numbers from user and add those two numbers.
In this program we take two numbers from user using gets
method and add those two numbers
puts "Enter first number:"
input1 = Integer(gets.chomp)
puts "Enter second number:"
input2 = Integer(gets.chomp)
result = input1 + input2
puts "Sum of the given two numbers is: #{result}"
Output:
Enter first number:
20
Enter second number:
30
Sum of the given two numbers is: 50