Question PSC-ARR-0004
EasyWhat will be the output of the following pseudocode?
Integer a[] = {2, 5, 8, 11}
Integer c = 0
for (each i from 0 to 3)
if (a[i] mod 2 == 0)
c = c + 1
end if
end for
Print c
- A.
3
- B.
4
- C.
Show answer and explanation
Answer: C
a[i] mod 2 == 0 picks the even elements, 2 and 8, so c = 2.