Percentage increase in volume of the cube if a side of cube is increased by a given percentage


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.

Examples:

Input: x = 10
Output: 33.1%

Input: x = 50
Output: 237.5%

Approach

Below is the implementation of the above approach:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ program to find percentage increase
// in the volume of the cube
// if a side of cube is increased
// by a given percentage
  
#include <bits/stdc++.h>
using namespace std;
  
void newvol(double x)
{
    cout << "percentage increase "
         << "in the volume of the cube is "
         << pow(x, 3) / 10000 + 3 * x
                + (3 * pow(x, 2)) / 100
         << "%" << endl;
}
  
// Driver code
int main()
{
    double x = 10;
    newvol(x);
    return 0;
}
chevron_right

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java program to find percentage increase
// in the volume of the cube
// if a side of cube is increased
// by a given percentage
import java.io.*;
  
class GFG 
{
  
static void newvol(double x)
{
    System.out.print( "percentage increase "
    +"in the volume of the cube is "
        + (Math.pow(x, 3) / 10000 + 3 * x
                + (3 * Math.pow(x, 2)) / 100) );
                System.out.print("%");
}
  
// Driver code
public static void main (String[] args)
{
    double x = 10;
    newvol(x);
}
}
  
// This code is contributed by anuj_67..
chevron_right

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program to find percentage increase
# in the volume of the cube
# if a side of cube is increased
# by a given percentage
  
def newvol(x):
  
    print("percentage increase"
            "in the volume of the cube is ",
            ((x**(3)) / 10000 + 3 * x
                + (3 * (x**(2))) / 100),"%");
  
x = 10;
newvol(x);
  
# This code is contributed by PrinciRaj1992 
chevron_right

filter_none

edit
close

play_arrow

link
brightness_4
code

// C# program to find percentage increase
// in the volume of the cube
// if a side of cube is increased
// by a given percentage
using System;
  
class GFG 
{
  
static void newvol(double x)
{
    Console.Write( "percentage increase "
    +"in the volume of the cube is "
        + (Math.Pow(x, 3) / 10000 + 3 * x
                + (3 * Math.Pow(x, 2)) / 100) );
                Console.Write("%");
}
  
// Driver code
public static void Main ()
{
    double x = 10;
    newvol(x);
}
}
  
// This code is contributed by anuj_67..
chevron_right

Output:
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.




Article Tags :
Practice Tags :