Write a Ruby program which accept the radius of a circle from the user and compute the parameter and area

  • برمجة روبي
  • برمجة

 Write a Ruby program which accept the radius of a circle from the user and compute the parameter and area.

الأجوبة

Ruby Code:

radius = 5.0
perimeter = 0.0
area = 0.0
print "Input the radius of the circle: "
radius = gets.to_f
perimeter = 2 * 3.141592653 * radius
area = 3.141592653 * radius * radius
puts "The perimeter is #{perimeter}."
puts "The area is #{area}."
Output:
Input the radius of the circle: The perimeter is 31.41592653.
The area is 78.539816325.
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...