# Find the perimeter of a cylinder in C++

C++Server Side ProgrammingProgramming

#### C in Depth: The Complete C Programming Guide for Beginners

45 Lectures 4.5 hours

#### Practical C++: Learn C++ Basics Step by Step

Most Popular

50 Lectures 4.5 hours

#### Master C and Embedded C Programming- Learn as you go

66 Lectures 5.5 hours

Suppose we have the diameter and the height of the cylinder, we have to find the perimeter of the cylinder. As the perimeter is the outline of two dimensional object, then we cannot find the perimeter of one three dimensional object directly. We can make a cross section of the cylinder, and convert it as rectangle, then find the perimeter. The two sides of the rectangular cross section are the diameter, and the height. So perimeter is −

p=(2*d)+(2*h)

## Example

#include<iostream>
using namespace std;
int getCylinderPerimeter(int d, int h) {
return (2*d) + (2*h);
}
int main() {
int diameter = 5, height = 10;
cout << "Perimeter: " << getCylinderPerimeter(diameter, height) << " units";
}

## Output

Perimeter: 30 units
Updated on 04-Nov-2019 08:07:19