Find the perimeter of a cylinder - GeeksforGeeks

24 Nov, 2021
Given diameter and height, find the perimeter of a cylinder.Perimeter is the length of the outline of a two – dimensional shape. A cylinder is a three – dimensional shape. So, technically we cannot find the perimeter of a cylinder but we can find the perimeter of the cross-section of the cylinder. This can be done by creating the projection on its base, thus, creating the projection on its side, then the shape would be reduced to a rectangle. 
Formula : Perimeter of cylinder ( P ) = here d is the diameter of the cylinder h is the height of the cylinderExamples :  
Input : diameter = 5, height = 10 
Output : Perimeter = 30

Input : diameter = 50, height = 150 
Output : Perimeter = 400
 
 
C++
Java
Python
C#
PHP
Javascript
// CPP program to find // perimeter of cylinder#include <iostream>using namespace std;  // Function to calculate perimeterint perimeter(int diameter, int height){    return 2 * (diameter + height);}  // Driver functionint main(){    int diameter = 5;    int height = 10;          cout << "Perimeter = ";     cout<< perimeter(diameter, height);    cout<<" units\n";          return 0;}
// Java program to find // perimeter of cylinderimport java.io.*;  class GFG {      // Function to calculate perimeter    static int perimeter(int diameter, int height)    {        return 2 * (diameter + height);    }          /* Driver program to test above function */    public static void main(String[] args)    {        int diameter = 5;        int height = 10;        System.out.println("Perimeter = " +                         perimeter(diameter, height)                                        + " units\n");    }}  // This code is contributed by Gitanjali.
# Function to calculate # the perimeter of a cylinderdef perimeter( diameter, height ) :    return 2 * ( diameter + height )   # Driver functiondiameter = 5 ;height = 10 ;print ("Perimeter = ",            perimeter(diameter, height))
// C# program to find perimeter of cylinderusing System;  class GFG {      // Function to calculate perimeter    static int perimeter(int diameter, int height)    {        return 2 * (diameter + height);    }          /* Driver program to test above function */    public static void Main(String[] args)    {        int diameter = 5;        int height = 10;        Console.Write("Perimeter = " +                       perimeter(diameter, height)                                     + " units\n");    }}  // This code is contributed by parashar...
<?php// PHP program to find // perimeter of cylinder  // Function to calculate perimeterfunction perimeter($diameter, $height){    return 2 * ($diameter + $height);}      // Driver Code    $diameter = 5;    $height = 10;          echo("Perimeter = ");     echo(perimeter($diameter, $height));    echo(" units");      // This code is contributed by vt_m.?>
<script>  // javascript program to find // perimeter of cylinder  // Function to calculate perimeter    function perimeter(diameter, height)    {        return 2 * (diameter + height);    }  // Driver Function           let diameter = 5;        let height = 10;        document.write("Perimeter = " +                         perimeter(diameter, height)                                        + " units\n");          // This code is contributed by susmitakundugoaldanga.</script>
Output :  
Perimeter = 30 units
 
parashar
vt_m
susmitakundugoaldanga
area-volume-programs
Geometric
Mathematical
School Programming
Mathematical
Geometric
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Convex Hull | Set 1 (Jarvis's Algorithm or Wrapping)
Line Clipping | Set 1 (Cohen–Sutherland Algorithm)
Convex Hull | Set 2 (Graham Scan)
Check whether a given point lies inside a triangle or not
Convex Hull using Divide and Conquer Algorithm
Program for Fibonacci numbers
C++ Data Types
Write a program to print all permutations of a given string
Set in C++ Standard Template Library (STL)
Coin Change | DP-7