A while statement is similar to a repeat statement, except that the control condition is evaluated before the first execution of the statement sequence. Hence, if the condition is false, the statement sequence is never executed.
The syntax of a while statement is whileexpressiondostatement where expression returns a Boolean value and statement can be a compound statement. The while statement executes its constituent statement repeatedly, testing expression before each iteration. As long as expression returns True, execution continues.
Examples of while statements include while Data[I] <> X do I := I + 1;
while I > 0 do begin if Odd(I) then Z := Z * X; I := I div 2; X := Sqr(X);
while not Eof(InputFile) do begin
Readln(InputFile, Line); Process(Line); end;
Was this article helpful?
What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.