C MCQ Questions and Answers on Bitwise Operators

Image
C MCQ Questions and Answers

Study C MCQ Questions and Answers on C Bitwise Operators. Bitwise operators deal with ones and zeroes. Easily attend technical job interviews with these Multiple Choice Questions.

Go through C Theory Notes on Bitwise Operators before studying these questions.



1) What are Nibble, Word and Byte in computer language.?
A) Byte = 8 bits, Word= 4 Bytes, Nibble= 8 Bytes
B) Byte = 8 bits, Word=2 Bytes, Nibble=4 Bytes
C) Byte = 8 bits, Word=12 bits, Nibble=32 Bits
D) Byte = 8 bits, Word=24 bits, Nibble=40 Bits
Answer [=]
B
2) Choose correct representation of Decimal number in Binary.
A)
0   0000
1   0001
2   0010
3   0011
4   0100
B)
5   0101
6   0110
7   0111
8   1000
9   1001
C)
10  1010    A
11  1011    B
12  1100    C
13  1101    D  
14  1110    E
15  1111    F
D) All the above
Answer [=]
D
Explanation:

A B C D E and F are HEX or Hexadecimal notation.

printf("%X", 10);//A
printf("%x", 10);//a
3) What is the operator used to make 1's One's compliment.?
A) & Bitwise AND Operator
B) | Bitwise OR operator
C) ~ Bitwise Negate Operator
D) ^ Bitwise Exclusive OR
Answer [=]
C
Explanation:

One's complement is created by Negate Operator ~.

00010110 is changed to 11101001 after applying ~ operator.
4) What is the result of 0110 & 1100.?
A) 1000
B) 0100
C) 0001
D) 1010
Answer [=]
B
Explanation:

Bitwise & operator gives 1 if both operands are 1. 1&1 = 1.

0&0=0
0&1=0
1&0=0
1&1=1
5) What is the output of Bitwise OR operation | on (0110 | 1100).?
A) 1110
B) 1100
C) 1000
D) 1010
Answer [=]
A
Explanation:

Bitwise OR operation compares both operands. If at least one operand is 1 output is 1.

0|0=0
0|1=1
1|0=1
1|1=1
6) What is the output of Exclusive OR ^ operator on 0110^1000.?
A) 1000
B) 1110
C) 0011
D) 0001
Answer [=]
B
Explanation:

Exclusive OR ^ compares both operands. If both operands are different, output is 1.

0^0=1
0^1=1
1^0=1
1^1=0
7) What is the output of Left Shift Operator << on (00011000<<2).?
A) 01100000
B) 11000000
C) 00000110
D) 00000011
Answer [=]
A
Explanation:

Left Shift Operator << shifts bits on the left side and fills Zeroes on the Right end.



8) What is the result of Right Shift Operator >> on (00110000>>2).?
A) 11000000
B) 00001100
C) 01100000
D) 11001111
Answer [=]
B
Explanation:

Right Shift Operator shift bits on the right side and fills Zeroes on the left side.

9) Choose correct statement about Left Shift Operator << .?
A) Left shift operator shifts individual bits on the left side
B) When shifting left side, overflow bits are ignored.
C) Zeroes are filled on the right side
D) All the above
Answer [=]
D
10) Choose a correct statement about Right Shift Operator >> .?
A) Right shift operator shift individual bits on to the right side.
B) When shifting bits right side, overflow bits on the right are ignored or truncated.
C) Zeroes are filled on the left side.
D) All the above
Answer [=]
D
11) What is a Single Operand Operator below.?
A) &
B) |
C) ^
D) ~
Answer [=]
D
Explanation:

TILDE or Negation works on single Operand. ~1100=0011.

12) What is the Bitwise operator used to set a particular bit value to 1.?
A) & AND
B) | OR
C) ^ Exclusive OR
D) ~ Operator
Answer [=]
B
Explanation:

To set a 3 bit to 0 from right in 0000001, OR with 00000100. Output is 00000101.

13) What is the Bitwise operator used set a particular bit to Zero 0.?
A) & Operator
B) | OR operator
C) ^ Exclusive Operator
D) ~ TILDE Operator
Answer [=]
A
Explanation:

To set a 4th bit to 0, AND with 11110111.

 00111000 & 11110111 =00110000;
14) Which is Bit Toggling operator below.?
A) & AND operator
B) | OR operator
C) ^ Exclusive Operator
D) ~ TILDE operator
Answer [=]
D


15) Which is the format specifier used to prefix 0x and print a number in hexadecimal notation.?
A) %x
B) %0x
C) %#x
D) %hx
Answer [=]
C
Explanation:
printf("%#x", 10);
//output: 0xa
16) Left Shift operation is equivalent to.?
A) Division by 2
B) Multiplying by 2
C) Adding 2
D) Subtracting 2
Answer [=]
B
Explanation:

Yes. (0001)<<1 = 0010. 1 x 2= 2 i.e 10 in binary.

17) Right Shift operation >> is equivalent to .?
A) Multiplying by 2
B) Division by 2
C) Adding 2
D) Subtracting 2
Answer [=]
B
Explanation:

0100>>1 = 0010. So 4 / 2 = 2 = 10 in binary.

18) What is the minimum and maximum values in Octal Number System.?
A) 1 to 8
B) 0 to 7
C) 2 to 9
D) None of the above
Answer [=]
B
Explanation:

10 in decimal = 12 in octal = 1100 in Binary.

19) What number system is not understood by C language compiler directly.?
A) Decimal
B) Octal
C) Binary
D) Hex Decimal
Answer [=]
C
Explanation:

Yes. C language can not understand Binary language directly. Because C language is a High Level Language.

20) Choose a correct statement about C Bitwise operators.?
A) 0^number = number
B) 1 | number = number
C) 0 & number = 0
D) All the above
Answer [=]
D