def cylinder_volume(radius, height)
Math::PI * radius**2 * height
end
puts cylinder_volume(3, 5) #=> 141.3716694115407
main.rb
Explanation:- `Math`moduleisusedtogetthevalueofPi.- `cylinder_volume` function accepts two arguments - `radius`and`height`.
- The function calculates the volume of the cylinder using the formula `πr²h`.
- The calculated volume is returned by the function.
- The `puts` function is used to output the calculated volume for the given input values of radius=3and height=5.