# 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: ");
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);
}
}```
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

Note: Join free Sanfoundry classes at Telegram or Youtube

Surface_area = 4 * Pi * r * r,

Volume = 4 / 3 * Pi * r * r * r

where Pi = 22/7.

Runtime Test Cases
```
Enter the Radius of Sphere : 5
Surface Area of Sphere is : 314
Volume of Sphere is : 523.333333333333333```

Sanfoundry Global Education & Learning Series – 1000 C# Programs.

If you wish to look at all C# Programming examples, go to 1000 C# Programs.