=====
CS 111 - Week 13 Lecture 1 - 2024-11-19
=====

=====
TODAY WE WILL:
=====
*   announcements
*   intro to while loop!
*   prep for next class

*   should be working on Homework 10!
    *   at-least-first-attempts due by 11:59 pm this Friday, November 22

*   YES, there IS lab, with a lab exercise, on Friday, November 22!

=====
intro to while loops
(the while statement)
=====

*   syntax:

    while (bool_expr)
        statement;

    statement_after;

    *   but remember, a block "counts" as a single statement,
        so MUCH more commonly:

    while (bool_expr)
    {
        statement1;
	...
	statementN;
    }

    statement_after;

*   semantics:
    1.   the bool_expr is evaluated
    2.   if true, the while's statement/body is done
         ...then go back to step 1

         if false, you're done with this loop --
	 ...continue AFTER the loop's statement/body

*   the statement (typically the block) for a while
    statement is often called its body

    *   note that something in the while's body
        NEEEEEEDS to eventually be able to ensure that
	its bool_expr eventually becomes false!

        *   otherwise? you get an INFINITE loop
	    (it won't stop until YOU stop it,
	    something overflows, the operating system stops
	    it, something crashes, etc....!)

    *   frequently:
        *   the bool_expr will involve a local variable
	*   that local variable is changed in the loop body
	*   that change (or combination of changes) eventually
	    leads the bool_expr to be false

=====
SIDE NOTES: when your function has side-effects!
=====
*   when your function has side-effects,
    you are expected to describe them in your purpose statement
    (also add a "has the side-effect(s)" part)

*   when your function has side effects,
    you are expected to describe them as best you can in
    your tests (yes, this gets a bit kluge-y...!)
    *   and you need to add additional cout statement(s) to
        describe those side-effects in a testing main function
	as well

*   for example: see today's example function cheer

=====
additional notes about while statements:
=====
*   MOST COMMON ERRORS:
    *   going ONE TOO MANY times
    *   going ONE TOO FEW times
    *   going ZERO times (when you meant to repeat)
    *   never stopping...!  <-- infinite loop