Given the length of space diagonal of a cube as d. The task is to calculate the volume occupied by the cube with the given length of space diagonal. Space diagonal is a line connecting two vertices that are not on the same face.
Input: d = 5 Output: Volume of Cube: 24.0563 Input: d = 10 Output: Volume of Cube: 192.45
Volume of cube whose space diagonal is given:
Let d = the length of diagonal |AB| and
let a = the length of each side of the cube.
Pythagorus #1 in triangle ACD:
Pythagorus #2 in triangle ABC:
Now we can solve for a in terms of d:
This means that the volume V is:
Below is the required implementation:
Volume of Cube: 24.0563
Time Complexity: O(1)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Percentage increase in volume of the cube if a side of cube is increased by a given percentage
- Program for Volume and Surface Area of Cube
- Length of a Diagonal of a Parallelogram using the length of Sides and the other Diagonal
- Find the diagonal of the Cube
- Maximum sum of elements in a diagonal parallel to the main diagonal of a given Matrix
- Find the concentration of a solution using given Mass and Volume
- Find Cube root of a number using Log function
- Area of a Square | Using Side, Diagonal and Perimeter
- Length of diagonal of a parallelogram using adjacent sides and angle between them
- Program for Volume and Surface Area of Cuboid
- Calculate Volume, Curved Surface Area and Total Surface Area Of Cylinder
- Calculate Volume and Surface area Of Sphere
- Calculate volume and surface area of a cone
- Program for volume of Pyramid
- Program to calculate volume of Ellipsoid
- Maximize volume of cuboid with given sum of sides
- Program to calculate area and volume of a Tetrahedron
- Program to calculate Volume and Surface area of Hemisphere
- Program for Volume and Surface area of Frustum of Cone
- Program to calculate volume of Octahedron
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.