Aumento porcentual en el cilindro si la altura aumenta en un porcentaje dado pero el radio permanece constante

Aquí se da un cilindro circular recto, cuya altura aumenta en un porcentaje dado, pero el radio permanece constante. La tarea es encontrar el porcentaje de aumento en el volumen del cilindro.
Ejemplos: 
 

Input: x = 10
Output: 10%

Input: x = 18.5
Output: 18.5%

Enfoque
 

  • Sea, el radio del cilindro = r
  • altura del cilindro = h
  • incremento porcentual dado = x%
  • entonces, volumen antiguo = π*r^2*h
  • nueva altura = h + hx/100
  • nuevo volumen = π*r^2*(h + hx/100)
  • entonces, aumento de volumen = πr^2*(hx/100)
  • entonces porcentaje de aumento en volumen = (πr^2*(hx/100))/(πr^2*(hx/100))*100 = x


 

C++

// C++ program to find percentage increase
// in the cylinder if the height
// is increased by given percentage
// but radius remains constant
 
#include <bits/stdc++.h>
using namespace std;
 
void newvol(double x)
{
    cout << "percentage increase "
         << "in the volume of the cylinder is "
         << x << "%" << endl;
}
 
// Driver code
int main()
{
    double x = 10;
    newvol(x);
    return 0;
}

Java

// Java program to find percentage increase
// in the cylinder if the height
// is increased by given percentage
// but radius remains constant
import java.io.*;
 
class GFG
{
 
static void newvol(double x)
{
    System.out.print( "percentage increase "
        + "in the volume of the cylinder is "
        + x + "%" );
}
 
// Driver code
public static void main (String[] args)
{
    double x = 10;
    newvol(x);
}
}
 
// This code is contributed by anuj_67..

Python3

# Python3 program to find percentage increase
# in the cylinder if the height
# is increased by given percentage
# but radius remains constant
 
def newvol(x):
    print("percentage increase in the volume of the cylinder is ",x,"%")
 
# Driver code
x = 10.0
newvol(x)
 
# This code is contributed by mohit kumar 29

C#

// C# program to find percentage increase
// in the cylinder if the height
// is increased by given percentage
// but radius remains constant
using System;
 
class GFG
{
 
static void newvol(double x)
{
    Console.WriteLine( "percentage increase "
        + "in the volume of the cylinder is "
        + x + "%" );
}
 
// Driver code
public static void Main ()
{
    double x = 10;
    newvol(x);
}
}
 
// This code is contributed by anuj_67..

Javascript

<script>
// javascript program to find percentage increase
// in the cylinder if the height
// is increased by given percentage
// but radius remains constant
function newvol(x)
{
    document.write( "percentage increase "
        + "in the volume of the cylinder is "
        + x + "%" );
}
 
// Driver code
var x = 10;
newvol(x);
 
// This code is contributed by 29AjayKumar
</script>

Producción: 
 

percentage increase in the volume of the cylinder is 10.0%

Complejidad Temporal: O(1), ya que no hay bucle.

Espacio Auxiliar: O(1), ya que no se ha ocupado ningún espacio extra.

Publicación traducida automáticamente

Artículo escrito por IshwarGupta y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *