Question PSC-ARR-0002
EasyWhat will be the output of the following pseudocode?
Integer a[] = {3, 7, 1, 9, 4}
Integer s = 0
for (each i from 0 to 4)
s = s + a[i]
end for
Print s
- A.
25
- B.
24
- C.
Show answer and explanation
Answer: B
The loop adds every element: 3 + 7 + 1 + 9 + 4 = 24.