C++ 程序用于查找球体的体积和表面积

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

  • C++ 球体体积 = 4πr³
  • C++ 球体表面积 = 4πr²
#include<iostream>
#include <cmath>
using namespace std;

int main()
{
	float sp_Radius, sp_sa, sp_Volume;
	
	cout << "\nPlease Enter the radius of a Sphere = ";
	cin >> sp_Radius;
	
	sp_sa =  4 * M_PI * sp_Radius * sp_Radius;
	sp_Volume = (4.0/3) * M_PI * sp_Radius * sp_Radius * sp_Radius;
	
	cout << "\nThe Surface Area of a Sphere   =  " << sp_sa;
	cout << "\nThe Volume of a Sphere         =  " << sp_Volume;
		
 	return 0;
}
C++ Program to find Volume and Surface Area of a Sphere