yorick banner

Home

Manual

Packages

Global Index

Keywords

Quick Reference

Back: Loops Forward: for   FastBack: Conditionals Up: Loops FastForward: Scoping         Top: Yorick Contents: Table of Contents Index: Concept Index About: About this document

1.2.4.1 The while and do while statements

The while loop is simpler than the for loop:

 
while (condition) body_statement

The body_statement -- very oten a compound statement enclosed in curly braces -- executes over and over until the condition becomes false. If the condition is false to begin with, body_statement never executes.

Occasionally, you want the body_statement to execute and set the condition before it is tested for the first time. In this case, use the do while statement:

 
do {
  body_statement_A;
  body_statement_B;
  ...etc...
} while (condition);