Q:

Write a Ruby program which accept the radius of the sphere as input and compute the volume

0

Write a Ruby program which accept the radius of the sphere as input and compute the volume.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ruby Code:

r = 5.0
v = 0.0
pi = 3.141592653
print "Input the radius of the circle: "
r = gets.to_f
v = (4/3)* (pi)* (r**3)
puts "The volume of the sphere is : #{v}."
Output:
Input the radius of the circle: The volume of the sphere is : 392.699081625.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now