C++ 程序查找圆柱体的体积和表面积

编写一个 C++ 程序,通过示例查找圆柱体的体积和表面积。此 C++ 程序允许用户输入圆柱体的半径和高度。接下来,我们使用数学公式计算圆柱体的表面积、侧面积、顶面积和体积。它们是:

  • C++ 圆柱体体积 = πr²h
  • C++ 圆柱体顶面积 = πr²
  • C++ 圆柱体表面积 = 2πr² + 2πrh
  • C++ 圆柱体侧面积 = 2πrh
#include<iostream>
#include <cmath>
using namespace std;

int main()
{
	float cy_Radius, cy_Height, cy_sa, cy_Volume, cy_LSA, cy_TopSA;
	
	cout << "\nPlease Enter the Radius of a Cylinder = ";
	cin >> cy_Radius;
	
	cout << "\nPlease Enter the Height of a Cylinder = ";
	cin >> cy_Height;
	
	cy_sa = 2 * M_PI * cy_Radius * (cy_Radius + cy_Height);
	cy_Volume = M_PI * cy_Radius * cy_Radius * cy_Height;
	cy_LSA = 2 * M_PI * cy_Radius * cy_Height; //cy_LSA= Lateral Surface Area of Cylinder
	cy_TopSA = M_PI * cy_Radius * cy_Radius; // cy_TopSA = Top Surface Area
	
	cout << "\nThe Surface Area of a Cylinder           =  " << cy_sa;
	cout << "\nThe Volume of a Cylinder                 =  " << cy_Volume;
	cout << "\nThe Lateral Surface Area of a Cylinder   =  " << cy_LSA;
	cout << "\nTop or Bottom Surface Area of a Cylinder =  " << cy_TopSA;
		
 	return 0;
}
C++ Program to find Volume and Surface Area of a Cylinder