How to find the Division of Two Numbers in Ruby - Step by Step Examples
How to find the Division of Two Numbers in Ruby ?
Answer
To divide two numbers in Ruby, you can use the '/' operator.
✐ Examples
1 Division of Two Numbers
In this example,
- We declare variables
numerator
anddenominator
and assign values to them. - We perform the division operation using the
/
operator and print the result.
Ruby Program
numerator = 20
denominator = 5
quotient = numerator / denominator.to_f
puts "Division of #{numerator} by #{denominator} is: #{quotient}"
Output
Division of 20 by 5 is: 4.0
Summary
In this tutorial, we learned How to find the Division of Two Numbers in Ruby language with well detailed examples.