中等ICT-ALGO-002

What is the output of this pseudocode? sum ← 0; FOR i FROM 1 TO 3; sum ← sum + i; END FOR; OUTPUT sum

A. 0
B. 6✓ 答案
C. 3
D. 4

解說

sum becomes 1, then 3, then 6. The output is the sum, not the final value of i and not the starting 0.

「演算法與偽代碼」全部 12 題 · 資訊及通訊科技 MCQ 題庫