#include<iostream> #include<cmath> using namespace std;
const double PI = 3.14159;
// returns the area of a circle with the specified radius
double area(double radius);
// returns the volume of a sphere with the specified radius
double volume(double radius);
int main() {
double radius;
cout << "Enter a radius (in inches): ";
cin >> radius;
cout << "Radius = " << radius << " inches\n"
<< "Area of circle = " << area(radius)
<< " square inches\n"
<< "Volume of sphere = " << volume(radius)
<< " cubic inches\n";
return 0;
}
double area(double radius) {
return PI*pow(radius, 2); }
double volume(double radius) { return 4.0/3*PI*pow(radius,3); }
|