Volume of a cube = side * side * side.
The cube has all the edges of the same length. The volume of a cube can be calculated by multiplying the length of an edge by itself twice. So if the length of an edge is 4, the volume is 4 x 4 x 4 = 64
Algorithm
- Define the value of variable 'a' as the length of an edge of the cube.
- Multiply 'a' with 'a' and again multiple the results with 'a' to obtain the volume of the cube.
- Define the variable volume_cube and assign the volume of the cube to it.
Complexity
O(1)
Input:
side = 4
Output:
Volume of cube = side3
= 43
= 64
C Program
Output:
PHP Program
Output:
Java Program
Output:
C# Program
Output:
Python Program
Output: