ข้ามไปยังเนื้อหา

การทำซ้ำ: WHILE และ REPEAT

English

WHILE tests first

  • A pre-condition loop tests the condition, then maybe runs the body.
  • If the condition is already FALSE, the body never runs.
  • The block ends at ENDWHILE.

WHILE tests Money < 1000 before the body, so it may run zero times; REPEAT runs Total ← Total + 7 and then tests Total > 20, so it runs at least once

เอกสารประกอบการเรียน

เข้าสู่ระบบหรือสร้างบัญชี

IGCSE, A-Level & AP