Given here is a cube, whose one side is increased by a given percentage. The task is to find percentage increase in the volume of the cube.
Input: x = 10 Output: 33.1% Input: x = 50 Output: 237.5%
- In a cube, all sides are equal, so,
length = breadth = height
- let side of the cube = a
- given percentage increase = x%
- so, volume before increase = a^3
- after increase, new side = a + ax/100
- so, new volume = (a + ax/100)^3 = a^3 + (ax/100)^3 + 3a^3x/100 + 3a^3x^2/10000
- increase in volume = new volume – old volume = (a^3 + (ax/100)^3 + 3a^3x/100 + 3a^3x^2/10000) – a^3 = (ax/100)^3 + 3a^3x/100 + 3a^3x^2/10000
- so, percentage increase in volume = (((ax/100)^3 + 3a^3x/100 + 3a^3x^2/10000)/a^3) * 100 = ((x/100)^3 + 3x/100 + 3x^2/10000) * 100 = x^3/10000 + 3x + 3x^2/100
Below is the implementation of the above approach:
percentage increase in the volume of the cube is 33.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.