C Arrays Quiz – 20 Questions with Answers
20 questions · 15 min · Medium
Test your knowledge of bitwise operators in C with 15 questions covering AND, OR, XOR, NOT, left shift, right shift, bit manipulation, and binary operations.
No sign-up needed · Last updated:
Score: 0 00:00
Create a free account to keep your scores and track your progress. It is optional.
20 questions · 15 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
A. &
The & operator performs a bitwise AND operation on the corresponding bits of two operands.
B. |
The | operator performs a bitwise OR operation on the corresponding bits of two operands.
A. ^
The ^ operator performs a bitwise exclusive OR operation. A result bit is 1 when the corresponding input bits are different.
B. ~
The ~ operator performs a bitwise NOT operation and flips each bit of its operand.
A. 1
In binary, 5 is 101 and 3 is 011. Performing 101 & 011 gives 001, which is 1.
C. 7
In binary, 5 is 101 and 3 is 011. Performing 101 | 011 gives 111, which is 7.
C. 6
In binary, 5 is 101 and 3 is 011. XOR gives 110, which is 6.
B. <<
The << operator shifts the bits of its left operand toward the left by the specified number of positions.
A. >>
The >> operator shifts the bits of its left operand toward the right by the specified number of positions.
C. 8
The binary representation of 4 is 100. Shifting it left by one position produces 1000, which is 8.
B. 2
The binary representation of 8 is 1000. Shifting it right by two positions produces 0010, which is 2.
A. Bitwise AND
A bitwise AND operation with an appropriate mask can be used to determine whether a specific bit is set.
B. Bitwise OR with a mask
Using bitwise OR with a mask containing 1 at the target position sets that bit to 1.
C. Bitwise XOR
XOR with a mask containing 1 at a particular position toggles that bit: 0 becomes 1 and 1 becomes 0.
B. & operates on bits, while && performs a logical AND operation
The & operator performs a bitwise operation on integer operands, while && evaluates the logical truth of its operands.