This program takes two integers as input and store in a separate variables num1 and num2. After the calculation, the result will be stored in another variable result and it will print the result.
Copy the below ruby program and execute it to see the real time output.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | =begin Ruby program to divide two numbers. =end # input the numbers and converting # them into integer puts "Enter first value: " num1=gets.chomp.to_i puts "Enter second value: " num2=gets.chomp.to_i # finding divide result=num1/num2 # printing the result puts "The result is #{result}" |
Program Output
1 2 3 4 5 6 | First run: Enter first value: 150 Enter second value: 5 The result is 30 |
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.