Ruby program to calculate circle area

Views: 509   

Following program shows you how to calculate circle area.
In this tutorial will get circle radius from user and calculate area and prints it using following formula
Area = PI X r X r

 puts "Please enter the radius of circle:"
 circleRadius = gets.to_f
 areaOfCircle = 22/7* (circleRadius * circleRadius)
 puts "Area of circle is: #{areaOfCircle}"


Please enter the radius of circle:
Area of circle is: 30.720
On By