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 cylinder

Examples :

Input : diameter = 5, height = 10 Output : Perimeter = 30 Input : diameter = 50, height = 150 Output : Perimeter = 400

## C++

`// CPP program to find ` `// perimeter of cylinder ` `#include <iostream> ` `using` `namespace` `std; ` ` ` `// Function to calculate perimeter ` `int` `perimeter(` `int` `diameter, ` `int` `height) ` `{ ` ` ` `return` `2 * (diameter + height); ` `} ` ` ` `// Driver function ` `int` `main() ` `{ ` ` ` `int` `diameter = 5; ` ` ` `int` `height = 10; ` ` ` ` ` `cout << ` `"Perimeter = "` `; ` ` ` `cout<< perimeter(diameter, height); ` ` ` `cout<<` `" units\n"` `; ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to find ` `// perimeter of cylinder ` `import` `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. ` |

*chevron_right*

*filter_none*

## Python

`# Function to calculate ` `# the perimeter of a cylinder ` `def` `perimeter( diameter, height ) : ` ` ` `return` `2` `*` `( diameter ` `+` `height ) ` ` ` `# Driver function ` `diameter ` `=` `5` `; ` `height ` `=` `10` `; ` `print` `(` `"Perimeter = "` `, ` ` ` `perimeter(diameter, height)) ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find perimeter of cylinder ` `using` `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... ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program to find ` `// perimeter of cylinder ` ` ` `// Function to calculate perimeter ` `function` `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. ` `?> ` |

*chevron_right*

*filter_none*

Output :

Perimeter = 30 units

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- C Program for Find the perimeter of a cylinder
- Java Program for Find the perimeter of a cylinder
- Python Program for Find the perimeter of a cylinder
- Calculate Volume, Curved Surface Area and Total Surface Area Of Cylinder
- Largest cube that can be inscribed within a right circular cylinder
- Longest rod that can be inserted within a right circular cylinder
- Volume of largest right circular cylinder within a Sphere
- Volume of biggest sphere within a right circular cylinder
- Largest right circular cylinder that can be inscribed within a cone
- Largest right circular cylinder within a frustum
- Largest right circular cylinder within a cube
- Largest right circular cylinder that can be inscribed within a cone which is in turn inscribed within a cube
- Largest sphere that can be inscribed in a right circular cylinder inscribed in a frustum
- Percentage increase in the cylinder if the height is increased by given percentage but radius remains constant
- Find perimeter of shapes formed with 1s in binary matrix
- Program to find Perimeter / Circumference of Square and Rectangle
- Find Perimeter of a triangle
- Program to find the Area and Perimeter of a Semicircle
- Program to find the Perimeter of a Regular Polygon
- Program to find all possible triangles having same Area and Perimeter

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.