စံကား

06

Control flow

Make decisions and repeat work.

So far, each program has run straight from the first line to the last. Real programs need to choose ("if the score is 40 or more, print pass") and to repeat ("print the numbers 1 to 100"). The order in which statements run is called control flow.

စံကား

Expected output

အောင်
၁
၂
၃

In this chapter

PageDoes
If and elserun statements when a condition is true
While loopsrepeat while a condition holds
Counted loopsrepeat once for each number in a range
Generic loopsa loop with its own counter, test and update
Break and continueleave a loop at once, or skip to its next round

Each of these runs an inner part: either one statement or a block (အောက်ပါတို့ကို လုပ်ဆောင်ပါ။ ... လုပ်ဆောင်စရာများ ပြီးပါပြီး။).

Next: If and else.