Write a C# Sharp program that takes the radius of a sphere as input and calculate and display the surface and volume of the sphere

  • برمجة سي شارب
  • برمجة

Write a C# Sharp program that takes the radius of a sphere as input and calculate and display the surface and volume of the sphere

C# Sharp: Area and volume of a sphere

A sphere is a perfectly round geometrical object in three-dimensional space that is the surface of a completely round ball.

In three dimensions, the volume inside a sphere is derived to be V = 4/3*π*r3 where r is the radius of the sphere

The area of a sphere is A = 4*π*r2

 

Sample Output:

Radius: 2                                                                                                     
50.26548                                                                                                                  
33.51032

 

الأجوبة

using System;
public class Exercise8
{
    public static void Main()
    {   
        float r;
        float pi = 3.1415926535f;
         
        Console.Write("Radius: ");
        r = Convert.ToSingle(Console.ReadLine());
         
        Console.WriteLine( 4 * pi * (r * r) );
         
        Console.WriteLine( 4f/3f * pi * (r * r * r));
    }
}
هل كان المحتوى مفيد؟

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

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