Find the perimeter of a cylinder in C++

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 −



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";


Perimeter: 30 units