Explanation
In this program, we have a cylinder with the given radius and height. We need to find its Surface area.
A cylinder is a three-dimensional geometrical figure/container with straight parallel sides and two circular cross-sections. So we have three surfaces of the cylinder.
The surface area of two circular cross-sections = 2( Π × r × r )
The surface area of parallel sides = Circumference times the height = 2 Π × r × h
Total Surface Area of Cylinder = 2( Π × r × r ) + 2 Π × r × h = 2 Π (r + h)
Formula
Surface Area of Cylinder = 2 Π (r + h)
Here, r is the radius and h is the height of the cylinder.
Π ( pi ) = 22/7 = 3.14
Algorithm
- Define the values of radius and height.
- Insert into given formula.
- Print the Surface Area of Cylinder.
Complexity
O(1)
Surface Area of Cylinder = 2 Π (r + h)
Input:
r = 2.0, h = 5.0
Output:
Surface Area of Cylinder = 2 Π (r + h)
Here, r = radius, h = height, and Π ( pie ) = 3.14
= 2 * 3.14 * ( 2.0 + 5.0)
= 44.00000
Python
Output:
C
Output:
JAVA
Output:
C#
Output:
PHP
Output: