Create C++ full program that calculates Surface Area of a Sphere, knowing that the
Surface Area of a Sphere = 4 pi r2 (where r is radius of circle) and PI = 3.14.
SOLUTION TO THE ABOVE QUESTION
SOLUTION CODE
#include<iostream>
using namespace std;
int main()
{
//prompt the user to enter the radius of the circle
int radius;
cout<<"\nEnter the radius of the circle: ";
cin>>radius;
double pi = 3.14;
//calculate the surface area of the sphere
double surface_area_of_a_sphere = 4 * pi * radius * radius;
cout<<"\nThe radius of the circle = "<<radius<<endl;
cout<<"\nThe surface area of the sphere = "<<surface_area_of_a_sphere<<endl;
return 0;
}
SAMPLE PROGRAM OUTPUT
Comments
Leave a comment