divide two numbers in ruby

To divide two numbers in Ruby, you can use the division operator /. Here's an example:

main.rb
numerator = 10
denominator = 5

result = numerator / denominator

puts result
# Output: 2
90 chars
8 lines

In this example, we first set the values of numerator and denominator to 10 and 5 respectively. We then use the division operator / to divide numerator by denominator, and store the result in a variable called result. Finally, we print out the value of result using puts. The output is 2, which is the result of dividing 10 by 5.

related categories

gistlibby LogSnag