Loops
Two main types
- determinate: we know in advance how many times the loop body will execute
- indeterminate: we do not know in advance how many times the loop body will execute
Two main subtypes
- pre-test: test first, then execute loop body; minimum number of executions: 0
- post-test: loop first, then test; minimum number of executions: 1
Questions to aid in selection
- Do we know how many times the loop body should execute?
- If yes, use a
forloop
- If yes, use a
- What is the minimum number of executions of the loop body?
- if 0, use a
whileloop - if 1, use a
do … whileloop
- if 0, use a
Arkin’s GNFRFCPWL
- write the boolean expression
- prime the boolean expression
- write the loop body
- refresh the boolean expression
touque.ca > Education Commons > Java > Resources > Control
[This page last updated 2020-12-23 at 12h13 Toronto local time.]

© 2007–2025 Hersch, Bear & Company Limited. All rights reserved. “Grammar Authority,” “grammarauthority.com,” “touque.ca,” and “Canada’s Thinking Cap” are trademarks of Hersch, Bear & Company Limited. All other trademarks and copyrights are the property of their respective owners.
Privacy Policy | Licence to Copy | How to cite | Contact us
