Write a complete program that prompts the user for the radius of a sphere, and calculates and prints the volume of that sphere.
Use an inline function sphereVolume that returns the result of the following expression:
```
(4.0 / 3.0 * 3.14159 * pow(radius, 3)).
```
```
// Exercise 6.10 Solution: ex06_10.cpp
// Inline function that calculates the volume of a sphere.
#include
#include
using namespace std;
const double PI{3.14159}; // define global constant PI
// calculates volume of a sphere
inline double sphereVolume(const double radius) {
return 4.0 / 3.0 * PI * pow(radius, 3);
}
int main() {
// prompt user for radius
cout << "Enter the length of the radius of your sphere: ";
double radiusValue;
cin >> radiusValue; // input radius
// use radiusValue to calculate volume of sphere and display result
cout << "Volume of sphere with radius " << radiusValue
<< " is " << sphereVolume(radiusValue) << endl;
}
```
You might also like to view...
Describe how a box plot can give information about whether the value of an attribute is symmetrically distributed. What can you say about the symme- try of the distributions of the attributes shown in Figure 3.11?
What will be an ideal response?
The ____ tool is useful for cloning large areas of non-specific data, like the sky or a shirt.
A. Clone Stamp B. Cloning Brush C. Heal D. Healing Brush