Multiple choice

What is the output of the given code?

int main()
{
 int i = 128<<2<<1<<0;
 switch(i)
 {
 default : printf(Bye); case 128<<4<<3<<2>>6 :
 printf(\\\\nHello); case 128<<4<<2<<2>>6 :
 printf(\\\\nKeep Calm); case 128<<4<<4<<2>>3 :
 printf(\\\\nGet Lost);
 }
 }

  1. ByeHello Keep CalmGet Lost

  2. Hello Keep CalmGet Lost

  3. Keep CalmGet Lost

  4. Get Lost

  5. Compiler error

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

The value of variable [ i ] after evaluating the expression would be (128 * (2^2) * (2^1) * (2^0)) = 1024. So, the switch case would become switch (1024). Now, the case expressions will be solved and the case having value 1024 will be executed. The first case evaluates to 1024. Therefore, all the statements of first case and all the other preceding cases will be executed until a break keyword is found. So, the output will be: Hello Keep CalmGet Lost. So, this answer is true.