C Bitwise Operations and Expressions

Test your knowledge of C programming bitwise operators, expression evaluation, and operator precedence with practical code output questions.

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

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
Question 2 Multiple Choice (Single Answer)

What is the output of the given program?

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

  1. 65536
  2. 1024
  3. 0
  4. 512
  5. Error at line 1
Question 3 Multiple Choice (Single Answer)

What is the output of the given program?

int main()
 {
 int x = 24;
 int y = 42;
 printf("%d",(~x) | (~y) );
 }

  1. - 25
  2. - 43
  3. - 9
  4. - 6
  5. Compiler error
Question 4 Multiple Choice (Single Answer)

What is the output of the given program?

int main()
{
 int x = 24;
 int y = 42;
 int z = 37;
 int a = 22;
 printf(%d,x&y|z^a);
 }

  1. 60
  2. 59
  3. 58
  4. 57
  5. 56
Question 5 Multiple Choice (Single Answer)

What is the output of the given code?

int main()
{
 int x = 24; int y = 42;
 int z = 37; int a = 22;
 printf(%d,x|y|z|a );
 }

  1. 64
  2. 59
  3. 62
  4. 63
  5. 77
Question 6 Multiple Choice (Single Answer)

What is the output of the given code?

int main()
 {
 printf("%d\\n",pow(128>>3>>2>>1,3));
 }

  1. 16
  2. 8
  3. 0
  4. 4
  5. Compiler error
Question 7 Multiple Choice (Single Answer)

What is the output of the given code?

int main()
 {
 int x = 24; int y = 42;
 int z = 37; int a = 22;
 printf("%d",x&y^z|x~a );
 }

  1. 63
  2. - 63
  3. 74
  4. - 74
  5. Compiler error
Question 8 Multiple Choice (Single Answer)

What is the output of the given code?

int main()
 {
 switch(printf("%d\\n",pow(128>>3>>2>>1,3))); case 56/4 :
printf("Hello"); case 32/4 : Printf("Bye"); case 0/9 :
Printf("Good"); case 0/1 : Printf("Bad");
 }

  1. HelloByeGoodBad
  2. ByeGoodBad
  3. GoodBad
  4. Bad
  5. Compiler error
Question 9 Multiple Choice (Single Answer)

What is the output of the given code?

int main()
 {
 switch(printf("%d\\n",pow(128>>3>>2>>1,3)))
 {
 case 56/4 : printf("Hello"); case 32/4 :
printf("Bye"); case 0/9 :
printf("Good"); case 0/1 :
printf("Bad");
 }
 }

  1. 0 GoodBad
  2. 8ByeGoodBad
  3. 14HelloByeGoodBad
  4. 16
  5. Compiler error
Question 10 Multiple Choice (Single Answer)

What is the output of the given code?

int main()
 {
 int i=2;
 int j=3;
 int k=127;
 printf("%h",++k>>++j<

  1. 32
  2. 20
  3. 16
  4. Blank Output Screen
  5. Compiler error
Question 11 Multiple Choice (Single Answer)

Find out the output of the given program, if any, or find out the error. Give the answer of the program in binary language.

int main()
{
int a=7,b=15,c;
c=a|b;
printf("the result comes out to be is :- %d",c);
}

  1. The result comes out to be: 0111.
  2. The result comes out to be: 1111.
  3. The result comes out to be is: 1000.
  4. The result comes out to be is: 0110.
  5. Compiler error
Question 12 Multiple Choice (Single Answer)

What is the output of the given code?

int main()
{
 int i=2;
 int j=3;
 int k=127;
 printf(%hx,++k>>++j<

  1. 32
  2. 20
  3. 16
  4. 4
  5. Compiler error
Question 13 Multiple Choice (Single Answer)

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
Question 14 Multiple Choice (Single Answer)

What is the output of the given program?

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

  1. ByeHelloKeep CalmGet Lost
  2. HelloKeep CalmGet Lost
  3. Keep CalmGet Lost
  4. Get Lost
  5. Blank screen
Question 15 Multiple Choice (Single Answer)

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