Separate speaker notes to accompany presentation on logic with a focus on looping:

 

Slide #1:

This presentation deals with programming structure without reference to any programming languages. Since there are other presentations on selection/conditional if statements, this presentation will focus on looping or iteration.

Slide #2:

The three structures are all that is logically needed to write a procedural or structured program.  All programming commands can be incorporated into these three basic structures.

For more information about selection (conditions) see other presentations that focus on the if statement. This presentation will focus on the loop structure.

Slide #3:

This shows the DO while loop which is frequently used in programming to cause processing to be repeated until a specific condition is met.  When the condition is met the processing will not be executed and control will drop out of the loop.

In this structure, it is possible to never do the processing.  If the condition is not true, processing will not be done.

Slide #4:

In this structure, the processing is done once and then the condition is checked to see if it should be done again.  In this structure, the processing will always be done at least once since the check is after the completion of the processing.

The programmer has to decide which looping structure is appropriate for the specific problem that is being solved.

Note that the do while is more widely used especially when processing files or input data.

Slide #5:

Note that I use the term initializing read, priming read is another term that can be used.

When you are inputting a record you can use the word read, the word input, the word get or any word that implies retrieving a record from the file.  In these examples, I am retrieving the next sequential record from the file.

Slide #6:

In this slide, I am showing the specifics of the do while structure. I am using a counter to determine how many times I want to do a loop. I set the counter to the start point outside the loop. I then test the counter against the stop point to determine if I should process.  If I process, I increment the counter before looping back to check the condition again.  By incrementing the counter, I have changed the condition being tested.  Eventually the counter will not be less than the stop  point and I will end the loop.  Note that the condition I am using is comparing for less than. Different conditions can be used, for example I might check for less than or equal to instead of less than.

Slide #7:

In the do until loop, I will always process at least once.  I think it is clearer when writing the pseudocode, to show the until condition at the bottom of the loop rather then at the top.

Note that sometimes you do not want to test for equality. You might want to process until counter passes the stop point in which case you will test for greater than stop point.