TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Program to find the surface area of the cylinder

Program to find the surface area of the cylinder on fibonacci, factorial, prime, armstrong, swap, reverse, search, sort, stack, queue, array, linkedlist, tree, graph etc.

<< Back to PROGRAM

Program to find the surface area of the cylinder

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

  1. Define the values of radius and height.
  2. Insert into given formula.
  3. Print the Surface Area of Cylinder.

Complexity

O(1)


Solution

Python

r = 2.0  #radius
h = 5.0 #height
surfacearea = (2*22*(r + h))/7 #calculation
print ("Surface Area Of Cylinder : ");
print (surfacearea); #prints surface area

Output:

Surface Area Of Cylinder :   44.0

C

#include<stdio.h>
int main() 
  { 
    float r,  h, surfacearea;
    r=2.0; 
    h = 5.0;
    surfacearea = (2*22*(r + h))/7;
    printf("\n\n Surface Area of Cylinder is : %f", surfacearea);
    return (0);
   }

Output:

Surface Area of Cylinder is: 44.00000

JAVA

            public class test
            {
             public static void main(String args[])
            {
             float r, h, surfacearea;
              r = 2;
              h  = 5;
              surfacearea = (22*r*(r+h))/7;
              System.out.println("Surface Area of Cylinder is: "+surfacearea);
            }
            }

Output:

Surface Area of Cylinder is:  44.000000

C#

using System;
class Program
{
    static void Main() 
    {
        float r, h, surfacearea;
        r  = 2;
        h = 5; 
        surfacearea = (22*r*(r+h))/7;
        Console.WriteLine("Surface Area of Cylinder is:"+surfacearea);
    }
}

Output:

Surface Area of Cylinder is:  44

PHP

<?php
$r = 2.0;
$h =  5.0;
$surfacearea =(22*$r*($r+$h))/7;
echo("Surface Area Of Cylinder is = ");
echo($surfacearea);
?>

Output:

Surface Area Of Cylinder is = 44

Next Topic#




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf