repeat statements

Top  Previous  Next

repeat statements

 

The syntax of a repeat statement is repeat statement1; ...; statementn; until expression where expression returns a Boolean value. The repeat statement executes its sequence of constituent statements continually, testing expression after each iteration. When expression returns True, the repeat statement terminates. The sequence is always executed at least once because expression is not evaluated until after the first iteration.

 

Examples:

 

repeat

 K := I mod J;

 I := J;

 J := K;

until J = 0;

 

repeat

 Write('Enter a value (0..9): ');

 Readln(I);

until (I >= 0) and (I <= 9);