Answer to Question #324622 in C++ for Klay

Question #324622

Write a computeSphere() function that returns the volume and surface area. Implement a

main function which reads the radius, calls the above function and prints the result.


1
Expert's answer
2022-04-06T02:28:00-0400
#include <iostream>
using namespace std;

const float pi = 3.14159;
 
//  Volume Of Sphere
float volume(float r) {
    float vol;
    vol = (4.0 / 3.0) * pi * r * r * r;
    return vol;
 
}
 
//  Surface Area of Sphere
float surface_area(float r)
{
    float sur_ar;
    sur_ar = 4.0 * pi * r * r;
    return sur_ar;
}
 
int main() {
    float radius;
    float vol, sur_area;
    
      cout<<"Enter Radius: ";
      cin>>radius;
      cout<<endl;
          
    vol = volume(radius);
    sur_area = surface_area(radius);
 
    cout << "Volume Of Sphere:  " << vol << endl;
    cout << "Surface Area Of Sphere: " << sur_area << endl;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS