Module 6 · Loops and Jump Statements
for: Init, Condition, Update, Traced
Free with an accountReading
Bob had one job before the school raffle: print the ticket numbers 1 to 10. He typed a loop in a hurry and sent the list to the printer. It stopped at 9. The owner of ticket 10 found out at the prize table.
Checking what this lesson needs for you…
What is inside for: Init, Condition, Update, Traced
- The for header: init, condition, update
- The order the parts run in, traced
- A for is a while with its parts gathered
- Counting down, counting in steps, and for (;;)
- The loop variable lives only inside the loop
- Off by one: which comparison to write
- Leave the loop variable alone in the body
- Two counters and the comma
- Checking a loop against a formula