do…while

説明

do…whileループは、whileループと同じように動作しますが、ループの最後に条件がテストされるため、doループは常に最低1回は実行されます。

構文

do {
// statement block
} while (condition);

condition: 真または偽と評価されるブール式。

プログラム例

int x = 0;
do {
  delay(50);          // wait for sensors to stabilize
  x = readSensors();  // check the sensors
} while (x < 100);
タイトルとURLをコピーしました