Given a right circular cylinder of height , & radius . The task is to find the length of the longest rod that can be inserted within it.
Input : h = 4, r = 1.5 Output : 5 Input : h= 12, r = 2.5 Output : 13
From the figure, it is clear that we can get the length of the rod by using pythagoras theorem, by treating the height of cylinder as perpendicular, diameter as base and length of rod as hypotenuse.
So, l2 = h2 + 4*r2.
l = √(h2 + 4*r2)
Below is the implementation of the above approach:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Largest right circular cylinder within a frustum
- Largest right circular cylinder within a cube
- Volume of largest right circular cylinder within a Sphere
- Largest right circular cylinder that can be inscribed within a cone
- Largest cube that can be inscribed within a right circular cylinder
- Volume of biggest sphere within a right circular cylinder
- 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
- Smallest Integer to be inserted to have equal sums
- Count of available non-overlapping intervals to be inserted to make interval [0, R]
- Minimum elements inserted in a sorted array to form an Arithmetic progression
- Find the perimeter of a cylinder
- Count of elements to be inserted to make Array sum twice the XOR of Array
- Percentage increase in the cylinder if the height is increased by given percentage but radius remains constant
- Calculate Volume, Curved Surface Area and Total Surface Area Of Cylinder
- Circular primes less than n
- Area of a Circular Sector
- Check whether a number is circular prime or not
- Time taken by two persons to meet on a circular track
- Program to find area of a Circular Segment
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.