C++ Program to find Volume and Surface Area of a Sphere

Write a C++ Program to Find the Volume and Surface Area of a Sphere with an example. This C++ program allows user to enter the radius of a sphere. Next, we are calculating the Surface Area and Volume of a sphere using mathematical formulas. They are

  • C++ Volume of a Sphere = 4πr³
  • C++ Surface Area of a Sphere = 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