ウィキのコピーミラー

これは pascal.chat のウィキのミラーです。編集、履歴、ログインはそちらで行います。

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

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

While ... DO loops

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

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

pascal
while ???????????? do
  ????????????;

ループはブール式が FALSE になるまで実行される。ループの中で用いられる変数の1つを変化させてブール式に影響を与えるようにしなくてはならない。さもないと無限ループという結果になってしまう。

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 としてはじまってしまうと、ループはまったく実行されない。

以下も参照のこと

FOR ...DO loops

Repeat... Until loops

For... in loops

previous contents next

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

第1版、最終更新:WikiArchive 。