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)
- Percentage increase in volume of the cube if a side of cube is increased by a given percentage
- Find the diagonal of the Cube
- Program for Volume and Surface Area of Cube
- N-th number which is both a square and a cube
- Centered cube number
- Largest cube that can be inscribed within the sphere
- Perfect cube greater than a given number
- Largest cone that can be inscribed within a cube
- Smallest perfect cube in an array
- Cube Free Numbers smaller than n
- Puzzle | Cut Blue Painted Cube
- Program for cube sum of first n natural numbers
- Largest right circular cylinder within a cube
- Find Cube Pairs | Set 2 (A n^(1/3) Solution)
- Find Cube Pairs | Set 1 (A n^(2/3) Solution)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.