This is a Java Program to Find the Volume and Surface Area of Sphere.
Formulas:
Sphere Volume = 4/3 * π * r3
Sphere Surface Area = 4 * π * r2
Here is the source code of the C# Program to Find the Volume and Surface Area of Sphere. The C# program is successfully compiled and run on a Windows system.
The program output is also shown below.
Source Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | static void Main(string[] args) { int r; double area, volume, pi = 3.14; Console.Write("Enter the radius of sphere: "); r = Convert.ToInt32(Console.ReadLine()); area = 3 * pi * r * r; volume = 1.333 * pi * r * r * r; Console.WriteLine("Surface Area of sphere:" + area); Console.WriteLine("Volume of sphere:" + volume); Console.ReadKey(); } |
Output:
what if you will use loop with radius of 1 to 20