Question:What will be output when you will execute following c code?#include<stdio.h>
void main(){
switch(5||2|1){
case 3&2:printf("Anatomy of a Murder");
break;
case -~11:printf("Planet of Apes");
break;
case 6-3<<2:printf("The conversation");
break;
case 5>=5:printf("Shaun of the Dead");
}
}
Choose all that apply:
A Anatomy of a Murder
B Planet of Apes
C The conversation
D Shaun of the Dead
E Compilation error
+ ExplanationConsider on the expression:
5||2|1
=5|| (2|1) //Bitwise or has higher precedence
=5||3
=1
Now, value of each case expression:
3&2 = 2
-~11 = -(-12) =12
6-3<<2 = 3 <<2= 12 5>=5 = 1
case -~11 and case 6-3<<2 have same constant expression i.e. case 12
In c duplicate case is not possible.