// FILE: AreaMain.cpp // FINDS AND PRINTS THE AREA AND CIRCUMFERENCE OF A CIRCLE // USING FUNCTIONS #include // global constant ... const double pi = 3.14159; // Functions used ... // COMPUTES THE AREA OF A CIRCLE double compute_area (double); // IN: radius of the circle // COMPUTES THE CIRCUMFERENCE OF A CIRCLE double compute_circum (double); // IN: radius of the circle // COMPUTES THE CIRCUMFERENCE OF A CIRCLE double compute_circum (double); // IN: radius of the circle // COMPUTES THE SQUARE OF A FLOATING-POINT NUMBER double square_double (double); // IN: number to be squared int main () { // Local data ... double radius; // input: radius of circle double area; // input: area of circle double circum; // output: circumference of circle // Read radius of circle. cout << "Enter the circle radius: "; cin >> radius; // Compute area of circle. area = compute_area (radius); // Compute circumference of circle. circum = compute_circum (radius); // Display area and circumference. cout << "The area of the circle is " << area << endl; cout << "The circumference of the circle is " << circum << endl; return 0; } // COMPUTES THE AREA OF A CIRCLE double compute_area (double r) // IN: radius of the circle { // Compute and return the area. return pi * square_double (r); } // end compute_area // COMPUTES THE CIRCUMFERENCE OF A CIRCLE double compute_circum (double r) // IN: radius of the circle { // Compute and return the circumference. return 2.0 * pi * r; } // end compute_circum // Insert definition for function square_double double square_double (double x) // IN: number to be squared { return x * x; }// end square_double