Skip to content
QuiznExam

Bitwise Operators in C Quiz – 15 Questions with Answers

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.

15
Questions
12 min
Time limit
Medium
Difficulty

No sign-up needed · Last updated:

Save your score

At least 8 characters.

Forgot password?

Related quizzes

const in C

15 questions · 12 min · Medium

All 15 questions and answers Spoilers: this shows the questions and answers. Try the quiz first! Open
  1. 1. Which operator is used for bitwise AND in C?

    • A. &
    • B. &&
    • C. |
    • D. ^
    Show answer

    A. &

    The & operator performs a bitwise AND operation on the corresponding bits of two operands.

  2. 2. Which operator is used for bitwise OR in C?

    • A. ||
    • B. |
    • C. &
    • D. ^
    Show answer

    B. |

    The | operator performs a bitwise OR operation on the corresponding bits of two operands.

  3. 3. Which operator is used for bitwise XOR in C?

    • A. ^
    • B. ^^
    • C. xor
    • D. &
    Show answer

    A. ^

    The ^ operator performs a bitwise exclusive OR operation. A result bit is 1 when the corresponding input bits are different.

  4. 4. Which operator is used for bitwise NOT in C?

    • A. !
    • B. ~
    • C. ^
    • D. -
    Show answer

    B. ~

    The ~ operator performs a bitwise NOT operation and flips each bit of its operand.

  5. 5. What is the result of 5 & 3 in C?

    • A. 1
    • B. 2
    • C. 3
    • D. 7
    Show answer

    A. 1

    In binary, 5 is 101 and 3 is 011. Performing 101 & 011 gives 001, which is 1.

  6. 6. What is the result of 5 | 3 in C?

    • A. 1
    • B. 6
    • C. 7
    • D. 8
    Show answer

    C. 7

    In binary, 5 is 101 and 3 is 011. Performing 101 | 011 gives 111, which is 7.

  7. 7. What is the result of 5 ^ 3 in C?

    • A. 1
    • B. 2
    • C. 6
    • D. 7
    Show answer

    C. 6

    In binary, 5 is 101 and 3 is 011. XOR gives 110, which is 6.

  8. 8. Which operator is used for a left bitwise shift in C?

    • A. <
    • B. <<
    • C. >>
    • D. <=
    Show answer

    B. <<

    The << operator shifts the bits of its left operand toward the left by the specified number of positions.

  9. 9. Which operator is used for a right bitwise shift in C?

    • A. >>
    • B. >
    • C. >>>
    • D. =>
    Show answer

    A. >>

    The >> operator shifts the bits of its left operand toward the right by the specified number of positions.

  10. 10. What is the result of 4 << 1 in C?

    • A. 2
    • B. 4
    • C. 8
    • D. 16
    Show answer

    C. 8

    The binary representation of 4 is 100. Shifting it left by one position produces 1000, which is 8.

  11. 11. What is the result of 8 >> 2 in C?

    • A. 1
    • B. 2
    • C. 4
    • D. 16
    Show answer

    B. 2

    The binary representation of 8 is 1000. Shifting it right by two positions produces 0010, which is 2.

  12. 12. Which bitwise operation can be used to check whether a particular bit is set?

    • A. Bitwise AND
    • B. Bitwise OR
    • C. Bitwise XOR
    • D. Bitwise NOT
    Show answer

    A. Bitwise AND

    A bitwise AND operation with an appropriate mask can be used to determine whether a specific bit is set.

  13. 13. Which operation can be used to set a particular bit to 1?

    • A. Bitwise AND with a mask
    • B. Bitwise OR with a mask
    • C. Bitwise NOT only
    • D. Right shift only
    Show answer

    B. Bitwise OR with a mask

    Using bitwise OR with a mask containing 1 at the target position sets that bit to 1.

  14. 14. Which operation can be used to toggle a particular bit?

    • A. Bitwise AND
    • B. Bitwise OR
    • C. Bitwise XOR
    • D. Bitwise NOT with no operand
    Show answer

    C. Bitwise XOR

    XOR with a mask containing 1 at a particular position toggles that bit: 0 becomes 1 and 1 becomes 0.

  15. 15. Which statement correctly distinguishes bitwise AND (&) from logical AND (&&) in C?

    • A. Both operators always perform exactly the same operation
    • B. & operates on bits, while && performs a logical AND operation
    • C. & is used only with floating-point values
    • D. && is used to shift bits
    Show answer

    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.