Multiple choice

What is the output of the given program?

int main()
{
printf(%d,128>>4>>3>>2);
// Line 1
}

  1. 2

  2. 4

  3. 0

  4. 8

  5. Error at line 1

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

This is the correct answer. The operator ( >>) is a right shift operator. The general formula to solve (N >> s) is: N/2^s. Here, 128>>4 will be solved first which is 128/(2^4) = 8. So, the statement now becomes 8>>3>>2. Now 8/(2^3) will be solved which will return (8/8) = 1. Now again the statement becomes 1>>2. So, 1/(2^2) will be solved resulting in 0. The correct output is zero.