Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 3/WHILE..DO/bg

Sent here from WHILE..DO/bg.

English · Français · Български · 中文(中国) · 日本語

While ... DO цикъл

(author: Tao Yue, state: unchanged)

Цикълът с предусловие има следната форма:

pascal
while BooleanExpression do
  statement;

Цикълът продължава да се изпълнява докато израза BooleanExpression не стане FALSE. В тялото на цикъла трябва да се въздейства по някакъв начин на израза като се промени някоя от променливите, които участват в него. В противен случай ще се получи безкраен цикъл:

pascal
a := 5;
while a < 6 do
  writeln (a);

Поправете тази ситуация, като промените стойността на променливата:

pascal
a := 5;
while a < 6 do
begin
  writeln (a);
  a := a + 1
end;

Цикълът WHILE ... DO се нарича цикъл с предусловие, защото условието се проверява преди да се изпълни тялото на цикъла. Ако условието се окаже FALSE, то тялото на цикъла while няма да се изпълни нито веднъж.

Виж също


From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 3/WHILE..DO/bg", 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.

Revision 1, last changed by WikiArchive .

Edited on wiki.freepascal.org by 2 people, 2021–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.

WhenWhoWhat changed
AlpinistbgCreated page
Alpinistbg (minor)
Kai BurghardtKai Burghardt moved page WHILE..DO/bg to Basic Pascal Tutorial/Chapter 3/WHILE..DO/bg: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [cf. [[Special: PermaLink/149778#Clut... (minor)
Kai Burghardtbypass redirects [cf. discussion]
Kai Burghardtbypass 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.