Skip to content · ⁨ข้ามไปยังเนื้อหา⁩

Count down in twos · ⁨นับถอยหลังแบบสอง⁩

English

Count down in twos

n starts at 10. Print 10, 8, 6, 4, 2 using a while loop.

The step does not have to be 1. Check where it stops: from 10 taking 2 each time, the value after 2 is 0, and 0 > 0 is false — so 0 is never printed.

ไทย

นับถอยหลังแบบก้าวละสอง

n เริ่มที่ 10. พิมพ์ 10, 8, 6, 4, 2 โดยใช้ลูป while

ขั้นเดิน (step) ไม่ต้องเป็น 1. ตรวจสอบว่ามันหยุดที่ไหน: จาก 10taking 2 ทุกครั้ง ค่าหลังจาก 2 คือ 0, และ 0 > 0 เป็นfalse — ดังนั้น 0 จะไม่ถูกพิมพ์เลย

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP