/*--- CS 111 - Week 9 Lecture 1 - 2025-10-21 Designing and test a C++ (non-main) function using the design recipe compile using: g++ 111lect09-1.cpp -o 111lect09-1 run using: ./111lect09-1 by: Sharon Tuttle last modified: 2025-10-21 ---*/ #include <cstdlib> #include <iostream> #include <string> #include <cmath> using namespace std; // this program's version of pi const double PI = 3.14159265358979; /*=== signature: circ_area: double -> double purpose: expects a circle's radius, and returns that circle's area tests: circ_area(PI) == pow(PI, 3) circ_area(1) == PI * 1 * 1 ===*/ double circ_area(double radius) { return PI * radius * radius; } /*--- test the function above, and also print the result from an example call ---*/ int main() { cout << boolalpha; cout << "*** Testing: circ_area ***" << endl; cout << (circ_area(PI) == pow(PI, 3)) << endl; cout << (circ_area(1) == PI * 1 * 1) << endl; cout << "Just for fun: " << endl; cout << circ_area(PI) << endl; cout << "^ (notice cout's default formatting for double values - " << endl; cout << "| it just prints the first 6-7 significant digits!)" << endl; return EXIT_SUCCESS; }