﻿ C# Sharp exercises: Program that takes the radius of a sphere as input and calculate and display the surface and volume of the sphere - w3resource

# C# Sharp Exercises: Calculate and display the surface and volume of a sphere

## C# Sharp Basic Data Types: Exercise-8 with Solution

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 Solution:-

C# Sharp Code:

``````using System;
public class Exercise8
{
public static void Main()
{
float r;
float pi = 3.1415926535f;

Console.WriteLine( 4 * pi * (r * r) );

Console.WriteLine( 4f/3f * pi * (r * r * r));
}
}
```
```

Sample Output:

```Radius: 2
50.26548
33.51032
```

Flowchart:

C# Sharp Code Editor: