Basic Pascal Tutorial/Chapter 3/WHILE..DO
Sent here from WHILE..DO.
English · Français · Български · 中文(中国) · 日本語
While ... DO loops
3Db - WHILE..DO (author: Tao Yue, state: unchanged)
The pretest loop has the following format:
while BooleanExpression do
statement;The loop continues to execute until the Boolean expression becomes FALSE. In the body of the loop, you must somehow affect the Boolean expression by changing one of the variables used in it. Otherwise, an infinite loop will result:
a := 5;
while a < 6 do
writeln (a);Remedy this situation by changing the variable's value:
a := 5;
while a < 6 do
begin
writeln (a);
a := a + 1
end;The WHILE ... DO loop is called a pretest loop because the condition is tested before the body of the loop executes. So if the condition starts out as FALSE, the body of the while loop never executes.
See also
From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 3/WHILE..DO", as it stood on 2022-08-20 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
Edited on wiki.freepascal.org by 8 people, 2007–2022
From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.
| When | Who | What changed |
|---|---|---|
| Kees | New page: 3Db - WHILE..DO The pretest loop has the following format: <font color="#006699"><strong>while</strong></font> BooleanExpression <font color="#006699"><strong>do</strong></font> state... | |
| Kees | ||
| Kees | ||
| Kees | ||
| Vincent | Text replace - "delphi>" to "syntaxhighlight>" (minor) | |
| Jwdietrich | ||
| Swen | (minor) | |
| Paskal | ||
| Paskal | See also | |
| FTurtle | ||
| FTurtle | ||
| Trev | Fixed syntax highlighting (minor) | |
| Kai Burghardt | Kai Burghardt moved page WHILE..DO to Basic Pascal Tutorial/Chapter 3/WHILE..DO: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [cf. [[Special: PermaLink/149778#Cluttering of... (minor) | |
| Kai Burghardt | bypass redirects [cf. discussion] | |
| Kai Burghardt | bypass language bar/categorization template redirect [cf. discussion] (minor) |
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
