The sphere can be defined as the round 3D object having a string of points located at a uniform distance from a particular point called center. It is perfectly symmetrical and has no edges or vertices.
A sphere with radius r has a volume of (4/3) x pie x radius2 and a surface area of 4 x pie x r2.
Formula
Surface area of sphere = 4 x pie x r2
Algorithm
- Define the radius of the sphere.
- Define the value of pie.
- Calculate the surface area of the sphere by 4 x pie x (radius x radius).
- Define surface_sphere and assign the surface area of the sphere to it.
Complexity
O(1)
Input:
Radius = 37, Pie = 3.14
Output:
Volume = 4 * pie * (radius * radius);
= 4 * 3.14 * 37 * 37
= 17210.285714
C Program
Output:
PHP Program
Output:
Java Program
Output:
C# Program
Output:
Python Program
Output: