这里给出的是一个右圆柱体,其高度增加了给定的百分比,但是半径保持不变。任务是找到气缸容积的百分比增加。
例子:
Input: x = 10
Output: 10%
Input: x = 18.5
Output: 18.5%
方法:
- 令,圆柱的半径= r
- 圆柱体高度= h
- 给定的百分比增长= x%
- 因此,旧体积= π* r ^ 2 * h
- 新高度= h + hx / 100
- 新体积= π* r ^ 2 *(h + hx / 100)
- 因此,音量增加= πr^ 2 *(hx / 100)
- 因此体积增加百分比= (π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
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
输出:
percentage increase in the volume of the cylinder is 10.0%