Answer to Question #328291 in C++ for Florence

Question #328291

Write a complete program that prompts the user for the radius of a sphere, calculates and prins the volume of that sphere. Use a function sphere volume that returs the results of the following expression: (4/3)*π*r3 which is equivalent to (4.0/3.0) *3.14159*pow(radius,3) in C++ code. Sample output Enter the length of the radius of your sphere: 2 volume of sphere with radius 2 is 33.5103


1
Expert's answer
2022-04-13T13:24:31-0400
#include <iostream>
#include <cmath>


int main() {
  const float PI = 3.14159;
  float radius;
  std::cout << "Enter the length of the radius of your sphere: ";
  std::cin >> radius;
  float volume = (4.0 / 3.0) * PI * std::pow(radius, 3);
  std::cout << "Volume of sphere with radius " << radius << " is " << volume << '\n';
  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