Question PSC-LOOP-0022
EasyWhat is the output of this pseudocode?
Integer s = 0
for (each i from 1 to 10)
if (i mod 2 == 0)
s = s + i
end if
end for
Print s
- A.
25
- B.
30
- C.
Show answer and explanation
Answer: B
Only the even values 2, 4, 6, 8 and 10 are added: 30.