![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 −
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
Advertisements