//an example of C++ functions //csci107, Laura Toma #include const float PI = 3.1412; //returns the circumference of a circle of radius rad float compute_circum(float rad) { return 2 * PI * rad; } //returns the area of a circle of radius rad float compute_area(float rad) { return PI * rad * rad; } int main() { char answer = 'y', option; float r; while (answer == 'y') { cout << "enter a radius: "; cin >> r; //read option cout <<"what would you like to compute? (press a for area, c for circumference): "; cin >> option; if (option == 'c') { cout << "The circumference is: " << compute_circum(r) << endl; } else if (option == 'a') { cout << "The area is: " << compute_area(r) << endl; } else { cout << "not a valid option..\n"; } //again? cout << "again? (y/n): "; cin >> answer; } }