// Properties of spheres of radii 1, 3, and 7 using function #include #include using namespace std; const double pi = 3.1416; double r; void Sphere() // defining a function { // function's body double area, volume; // variables local to this function area = 4.*pi*r*r; volume = 4./3.*pi*r*r*r; cout << r << ' ' << area << ' ' << volume << endl; } int main() { r=1.; { // function's body double area, volume; // variables local to this function area = 4.*pi*r*r; volume = 4./3.*pi*r*r*r; cout << r << ' ' << area << ' ' << volume << endl; } r=3.; { // function's body double area, volume; // variables local to this function area = 4.*pi*r*r; volume = 4./3.*pi*r*r*r; cout << r << ' ' << area << ' ' << volume << endl; } r=7.; { // function's body double area, volume; // variables local to this function area = 4.*pi*r*r; volume = 4./3.*pi*r*r*r; cout << r << ' ' << area << ' ' << volume << endl; } }