Multiple choice

What is the output of the given code?

int main()
{
 int i = 128<<4<<3<<2>>6;
 switch(i) { default : printf(Bye); case 65536 :
printf(\\\\nHello); case 32 :
printf(\\\\nGood Bye); case 8/2 :
printf(\\\\nSee U Later);//Line 1
 }
 }

  1. Hello Good ByeSee U Later

  2. Bye

  3. Bye Hello Good Bye See U Later

  4. Good ByeSee U Later

  5. Error at line 1

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

This is the correct answer. The value of variable [ i ], after evaluating the expression (128<<4<<3<<2>>6), will be 1024. The expression will be evaluated as: (128 * (2^4) * (2^3) * (2^2)) / (2^6) = 65536/64 = 1024. But we do not have any case of 1024 in switch statement; so default case will be executed and it will print “Bye”. But after default, we don’t have any break keyword; so all the cases will be executed until the break keyword is found. So, the correct output will be: Bye Hello Good Bye See U Later.