Enter the Radius of Sphere : 5 Surface Area of Sphere is : 314 Volume of Sphere is : 523.333333333333333
Users Online
· Guests Online: 8
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Newest Threads
No Threads created
Hottest Threads
No Threads created
Latest Articles
Articles Hierarchy
C# Program to Find Volume and Surface Area of Sphere
C# Program to Find Volume and Surface Area of Sphere
This is a C# Program to find volume and surface area of a sphere.
Problem Description
This C# Program finds Volume and Surface Area of a Sphere.
Problem Solution
Here radius and height of the sphere are obtained from the user and the surface area and its volume its calculated.
Program/Source Code
Here is source code of the C# Program to find Volume and Surface Area of a Sphere. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to find Volume and Surface Area of a Sphere */ using System; using System.IO; class program { public static void Main() { double r, surface_area, volume; double PI = 3.14; Console.WriteLine("Enter the Radius of the Sphere: "); r = Convert.ToDouble(Console.ReadLine()); surface_area = 4* PI * r * r; volume = (4.0 / 3) * PI * r * r * r; Console.WriteLine("Surface Area of Sphere is : {0} ", surface_area); Console.WriteLine("Volume of Sphere is : {0}", volume); Console.Read(); } }
Program Explanation
In this C# program, library function defined in <math.h> header file is used. We are reading the radius of the Sphere using ‘r’ variable. To compute the area and volume of the sphere the following formula is used
Surface_area = 4 * Pi * r * r,
Volume = 4 / 3 * Pi * r * r * r
where Pi = 22/7.
Runtime Test Cases
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.