/*--- Week 8 Lab Exercise *** MY GITHUB USERNAME IS: [put YOUR GitHub username here] *** *** Have I successfully logged into the CS50 IDE?: [put YOUR answer here] *** compile this program using: g++ lab8.cpp -o lab8 run using: ./lab8 create example output using: ./lab8 > lab8-out.txt *** by: [put YOUR NAME here] last modified: 2025-10-17 ---*/ /*--- these below are a little like BSL Racket's require expressions; they let us use useful functions from these C++ libraries ---*/ #include <cstdlib> #include <iostream> #include <string> #include <cmath> using namespace std; /*--- signature: rect_area: double double -> double purpose: expects a rectangle's length and width, and returns the area of that rectangle tests: rect_area(3.0, 3.1) == 9.3 rect_area(1.5, 4.0) == (1.5 * 4.0) ---*/ double rect_area(double length, double width) { return length * width; } /*--- A C++ program consists of one or more functions, one of which MUST have the name main; below is the main function for this program. After a C++ program is compiled, when you run the executable file resulting, it starts by running the main function. This main function prints the results from testing the function above, and also prints out the values of several other expressions. ---*/ int main() { // allow boolean values to be printed correctly cout << boolalpha; cout << "*** PUT YOUR NAME HERE ***" << endl; cout << "*** Testing: rect_area ***" << endl; cout << (rect_area(3.0, 3.1) == 9.3) << endl; cout << (rect_area(1.5, 4.0) == (1.5 * 4.0)) << endl; cout << endl; cout << "Just to see: " << endl; cout << rect_area(3.0, 3.1) << endl; cout << endl; cout << "OPTIONAL: want to print out an expression's value?\n" << " type it WITHIN the parentheses below: " << endl; cout << ("OPTIONAL: desired expression") << endl; cout << endl; return EXIT_SUCCESS; }