Answer to Question #343341 in C++ for menna

Question #343341

Write a C++ program that reads in the radius of a Sphere, then calculates and prints its volume and surface area. 


1
Expert's answer
2022-05-22T18:11:24-0400
#include <iostream>
using namespace std;
 
const float pi = 3.1415;

 float volume(float r) {
    return (float(4) / float(3)) * pi * r * r * r;
 }
 
float surface_area(float r) {
    return  4 * pi * r * r;
}
 
int main() {
    float radius;
    float vol, surfaceArea;
      
   cout<<"Enter radius: ";
   cin>>radius;
   
    vol = volume(radius);
    surfaceArea = surface_area(radius);
 
    cout << "Volume:  " << vol << endl;
    cout << "Surface: " << surfaceArea << 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
APPROVED BY CLIENTS