Open In App

Find the perimeter of a cylinder

Last Updated : 20 Feb, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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.
 

perimeter of a cylinder


Formula : 
Perimeter of cylinder ( P ) = ( 2 * d ) + ( 2 * h )
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;
}

                    

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.

                    

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))

                    

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...

                    

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.
?>

                    

Javascript

<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


Time Complexity: O(1) 
Auxiliary Space: O(1)
 



Previous Article
Next Article

Similar Reads

C Program for Find the perimeter of a cylinder
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
2 min read
Java Program for Find the perimeter of a cylinder
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
2 min read
Python Program for Find the perimeter of a cylinder
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
2 min read
Calculate Volume, Curved Surface Area and Total Surface Area Of Cylinder
Given radius and height of Cylinder, calculate the volume, total surface area and curved surface area of cylinder. Volume of Cylinder: The volume of cylinder is defined as the amount of three dimensional space occupied by the cylinder or the storage capacity of a cylinder. We can calculate volume of cylinder by using formula: where ' r 'is radius o
7 min read
Largest cube that can be inscribed within a right circular cylinder
Given here is a right circular cylinder of height h and radius r. The task is to find the volume of biggest cube that can be inscribed within it.Examples: Input: h = 3, r = 2 Output: volume = 27 Input: h = 5, r = 4 Output: volume = 125 Approach: From the figure, it can be clearly understand that side of the cube = height of the cylinder. So, the vo
4 min read
Longest rod that can be inserted within a right circular cylinder
Given a right circular cylinder of height [Tex]h [/Tex], &amp; radius [Tex]r [/Tex]. The task is to find the length of the longest rod that can be inserted within it. Examples: Input : h = 4, r = 1.5 Output : 5 Input : h= 12, r = 2.5 Output : 13 Approach: From the figure, it is clear that we can get the length of the rod by using pythagoras theorem
4 min read
Volume of largest right circular cylinder within a Sphere
Given a sphere of radius [Tex]R [/Tex]. The task is to find volume of the biggest right circular cylinder that can be inscribed within it.Examples: Input : R = 4 Output : 77.3495 Input : R = 5 Output : 151.073 Approach: let r be the radius of the right circular cylinder, and h be it's height.Volume of the cylinder, V = ?*r2*hAlso, r2 = R2 - h2 or,
4 min read
Volume of biggest sphere within a right circular cylinder
Given a right circular cylinder of radius [Tex]r [/Tex]and height [Tex]h [/Tex]. The task is to find the radius of the biggest sphere that can be inscribed within it.Examples: Input : r = 4, h = 8 Output : 4 Input : r = 5, h= 10 Output :5 Approach: From the diagram, it is clear that the radius of the sphere will be clearly equal to the base radius
4 min read
Largest right circular cylinder within a frustum
Given a frustum of height [Tex]h [/Tex], top-radius [Tex]r [/Tex]&amp; base-radius [Tex]R [/Tex]. The task is to find the volume of biggest right circular cylinder that can be inscribed within it.Examples: Input : r = 5, R = 10, h = 4 Output : 314 Input : r = 7, R = 11, h = 6 Output : 923.16 Approach: Let: The height of the cylinder = h1Radius of t
5 min read
Largest right circular cylinder within a cube
Given a cube of side length a. The task is to find the volume of biggest right circular cylinder that can be inscribed within it.Examples: Input : a = 4 Output : 50.24 Input : a = 5 Output : 98.125 Approach: Let: The height of the cylinder is h.Radius of the cylinder be r. From the diagram it is clear that: The height of the cylinder = side of cube
4 min read