Overview ������� (Loop) ������ while Statement ������ do-while Statement ������ for Statement ������ break ��� continue 2
����� Iteration Statement �������������� Loop ������ C ������ 4 ������� while statement do-while for statement break and continue statement 5
while statement flowchart Entry Statement 2 ex True Statement 1 pr False Exit 7
Example 1: ���� 10 ������ while loop Print count from 1 to 10 1 2 3 4 5 6 7 8 9 10 8
Example 2: Output 1. Withdraw 2. Show Balance 3. Transfer Enter your choice (1 -3): 5 Please input your choice correctly. 1. Withdraw 2. Show Balance 3. Transfer Enter your choice (1 -3): 1 Withdraw 10
do while statement flowchart Entry Statement 1 Statement 2 True ex pr False Exit 12
Example 3: ���� 10 ������ do while loop Print count from 1 to 10 1 2 3 4 5 6 7 8 9 10 13
Example 4: Output 1. Withdraw 2. Show Balance 3. Transfer Enter your choice (1 -3): 4 Please input your choice correctly. 1. Withdraw 2. Show Balance 3. Transfer Enter your choice (1 -3): 2 Show Balance 15
for statement syntax [cont. ] สามารถเปรยบเทยบกบการใช ไดดงน initial; while (condition) { statement 1; … statementn; incrementing; } while 18