Difference between revisions of "W1153 Repeat-While Loop"

From Coder Merlin
Line 3: Line 3:
* [[W1151 Conditional and Flow Chart]]
* [[W1151 Conditional and Flow Chart]]
* [[W1152 While Loop]]
* [[W1152 While Loop]]
== Repeat-While Loop ==
A '''repeat-while''' loop (which is also sometimes called a '''do-while''' loop):
* Executes the statements within the body of the loop
* Tests a condition
** If the condition is true, the statements within the body of the loop are again executed
** If the condition is false, execution continues with the statements ''after'' the body of the loop
{{Observe|Section 1|
# Compare this behavior to that of the '''while''' loop.  What are the similarities?  What are the differences?
# What are the minimum number of times that this loop will execute?
# What is the purpose of the ''Jump'' instruction after the ''consequent''?
}}


== Flowchart ==
== Flowchart ==

Revision as of 17:45, 12 January 2020

Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder
Infinite Loop 1

Prerequisites[edit]

Repeat-While Loop[edit]

A repeat-while loop (which is also sometimes called a do-while loop):

  • Executes the statements within the body of the loop
  • Tests a condition
    • If the condition is true, the statements within the body of the loop are again executed
    • If the condition is false, execution continues with the statements after the body of the loop
ObserveObserveIcon.png
Observe, Ponder, and Journal: Section 1
  1. Compare this behavior to that of the while loop. What are the similarities? What are the differences?
  2. What are the minimum number of times that this loop will execute?
  3. What is the purpose of the Jump instruction after the consequent?

Flowchart[edit]

   Repeat-While Loop Flowchart.png

Introduction[edit]

Topic Headers[edit]

Key Concepts[edit]

Exercises[edit]

References[edit]