Question 50 of 65Pseudocodepseudocode bitwise

What will be the output of the following pseudocode?

Note: & is bitwise AND and << is left shift
Integer x, k, s
Set x = 22, s = 0
for (each k from 0 to 4)
    if ((x & (1 << k)) != 0)
        s = s + k
    End if
End for
Print s

The verified answer and full solution are one login away

Every answer here is machine verified, with a step-by-step solution that teaches the method. Your login also unlocks a 7-question mock preview in the real exam interface.

Log in to see the answer
← Q49Q51 →Attempt the full timed mock