/*--- CS 111 - Week 13 Lecture 1 - 2025-11-18 compile using: g++ 111lect13-1.cpp -o 111lect13-1 run using: ./111lect13-1 by: Sharon Tuttle last modified: 2025-11-18 ---*/ #include <cstdlib> #include <iostream> #include <string> #include <cmath> using namespace std; /*=== signature: cheer: int -> int purpose: expects the number of HIPs in a cheer desired, has the SIDE-EFFECT of printing to the screen that many HIPs, each on their own line, followed by HOORAY!, and returns the number of HIPs actually printed tests: cheer(3) == 3 but also has the side-effect of printing to the screen: HIP HIP HIP HOORAY! cheer(5) == 5 but also has the side-effect of printing to the screen: HIP HIP HIP HIP HIP HOORAY! cheer(0) == 0 but also has the side-effect of printing to the screen: HOORAY! cheer(-13) == 0 but also has the side-effect of printing to the screen: HOORAY! ===*/ int cheer(int num_hips) { int count = 0; // print HIP to the screen num_hips times while (count < num_hips) { cout << "HIP" << endl; count = count + 1; } // ...THEN print HOORAY! cout << "HOORAY!" << endl; return count; } /*--- play around with local variables and mutation a bit, and test the function above ---*/ int main() { cout << boolalpha; int quant = 3; cout << "initially, quant: " << quant << endl; cout << "Enter a desired quantity: "; cin >> quant; cout << "after the cin, quant: " << quant << endl; quant = 126; cout << "after assignment, quant: " << quant << endl; int num; num = 100; num = num + 1; cout << "and now num is: " << num << endl; cout << endl; cout << "*** Testing: cheer ***" << endl; // put each of your function's tests into a cout statement // to print its result cout << "should see 3 HIPs then a HOORAY! then true" << endl; cout << (cheer(3) == 3) << endl; cout << "should see 5 HIPs then a HOORAY! then true" << endl; cout << (cheer(5) == 5) << endl; cout << "should see 0 HIPs then a HOORAY! then true" << endl; cout << (cheer(0) == 0) << endl; cout << "should see 0 HIPs then a HOORAY! then true" << endl; cout << (cheer(-13) == 0) << endl; return EXIT_SUCCESS; }