C++ Program to Compute Volume and Surface Area of Sphere
Write C++ Program to Compute Volume and Surface Area of Sphere
// CPP Program to Compute Volume and Surface Area of Sphere #include <iostream> #define PI 3.14 using namespace std; int main() { float radius = 4; double area_sphere; // Formula to compute area of sphere area_sphere = 4 * PI * (radius * radius); double volume; // Formula to compute volume of sphere volume = (4 * PI * radius * radius * radius)/3; cout << "Surface area of Sphere having radius " << radius << " :--> " << area_sphere; cout << "\nVolume of Sphere having radius " << radius << " :--> " << volume; return 0; }
Output:
Surface area of Sphere having radius 4.00 :--> 200.96
Volume of Sphere having radius 4.00 :--> 267.95