高階ICT-ALGO-015

What is the output? score ← 40 bonus ← 0 IF score >= 50 THEN bonus ← 10 ELSE bonus ← 5 ENDIF OUTPUT score + bonus

A. 50
B. 40
C. 10
D. 45✓ 答案

解說

40 is not greater than or equal to 50, so the ELSE branch sets bonus to 5. The output is 40 + 5 = 45. The THEN branch does not run.

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