=====
CS 111 - Week 13 Lecture 2 - 2025-11-20
=====

=====
TODAY WE WILL:
=====
*   announcements
*   more examples of while statements!
*   "classic" imperative repetition errors
*   a few words about PSEUDOCODE
*   [if time???] start intro to arrays <- will start Dec 2!
*   prep for next class

=====
*   Should be working on Homework 10!
    *   at least 1st attempts must be submitted by 11:59 pm
        on Friday, November 21

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

=====
*   if not yet done for Spring 2026 advising: 
    MEET WITH YOUR ADVISOR(S)!
    *   RE-CREATE your DARS plan!
    *   get ready to REGISTER for SPRING 2026 between November 10-21!

    *   CS and SE majors:
        *   in Spring 2026, you should take:
	    CS 112 - CS Foundations 2
	    Math 253 - Discrete Math

        *   You CAN take Math 101T - Trigonometry and Math 253 CONCURRENTLY
	
	*   You CAN ask to switch to another ENGL 103 section if it conflicts
	    with a major requirement such as CS 112 or Math 253 that you need
	    to stay on-track in your major!

=====
"classic" imperative-repetition (such as while statement) errors
=====
*   going ONE TOO FEW times
*   going ONE TOO MANY times
*   NEVER stopping <-- infinite loop
*   going ZERO times (when you WANTED at least one)

=====
quick note: loop control variable
=====
*   sometimes the local variable used to control a loop,
    especially to help determine when it should stop repeating,
    is called a loop control variable

=====
quick note: PSEUDOCODE
=====
*   esp. with local variables and mutation,
    imperative programming,
    we are getting more SEQUENCES of statements,
    in which the order MIGHT matter;

    *   pseudocode can be another tool
        as part of the "complete the function body step,
	AFTER writing the function's tests;

    *   what is pseudocode? [informal version]
        *   you write your logic -- your ALGORITHM --
	    in a natural-language-ish way, instead
	    in a particular programming language

        *   you write the steps in order!

        *   in a top-down approach, you might give "high-level" steps,
	    then gradually replace each high-level step
	    with lower-steps to do THAT task,
	    until you realize you know how to convert
	    your pseudocode steps into your desired programming
	    language, and then you can do that

        *   (in that conversion to C++, consider commenting
	    out the pseudocode that would be useful explanation
	    for a future reader)

    for example: this might be pseudocode for function sum_ints?

    set running sum to 0
    set next natural number to add to 1
    
    while still natural numbers to add
        add current natural number to add to running sum
	go to next natural number to add

    return resulting running sum