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

From Free Pascal wiki
Revision as of 15:38, 11 August 2015 by Derakun (talk | contribs) (Created page with "== While ... DO loops == {{WHILE..DO/ja}} 3Db - WHILE..DO (著者: Tao Yue, 状態: 原文のまま修正なし) プリテスト・ループは以下の形式をとる。 <s...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

While ... DO loops

Template:WHILE..DO/ja

3Db - WHILE..DO (著者: Tao Yue, 状態: 原文のまま修正なし)

プリテスト・ループは以下の形式をとる。

while ブール式 do
     文;

ループはブール式が 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

FOR ...DO loops

Repeat... Until loops

For... in loops


previous contents next