Iterative Statements : While Loop

While Loop

A WHILE LOOP is used when a set of statements has to be executed as long as a condition is true. The condition is evaluated at the beginning of each iteration. The iteration continues until the condition becomes false.

The General Syntax to write a WHILE LOOP is:
WHILE <condition>
LOOP statements;

Important steps to follow when executing a while loop:

  1. Initialise a variable before the loop body.
  2. Increment the variable in the loop.
  3. EXIT WHEN statement and EXIT statements can be used in while loops but it's not done oftenly.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License