Exercises

Binary Representation and Bitwise Operations Quiz

Explore how programs manipulate individual bits using AND, OR, XOR, NOT, shifts, and masks. This quiz covers binary calculations, setting and clearing bits, testing flags, extracting bit fields, unsigned overflow, parity, and common bit manipulation techniques. Questions progress from basic operator behavior to practical expressions used in systems programming, compact data storage, permissions, and hardware-oriented code.

Answer the questions below and check the explanation for each answer.

0/20 answered

  1. 1

    Which values can a single binary digit, or bit, represent?

  2. 2

    The image shows the 4-bit operands 1100 and 1010. What is the result of applying bitwise AND?

    Question 2
  3. 3

    The image shows the 4-bit operands 1100 and 1010. What is the result of applying bitwise OR?

    Question 3
  4. 4

    The image shows the 4-bit operands 1100 and 1010. What is the result of applying bitwise XOR?

    Question 4
  5. 5

    Using exactly 8 bits, what is the bitwise NOT of 00001111?

    Question 5
  6. 6

    For an unsigned value, what decimal result is produced by 5 << 2?

    Question 6
  7. 7

    For an unsigned value, what decimal result is produced by 40 >> 3?

    Question 7
  8. 8

    Which expression sets every bit selected by mask to 1 while leaving the other bits of x unchanged?

  9. 9

    Which expression clears every bit selected by mask while preserving unselected bits of x?

  10. 10

    Which operator toggles each bit selected by a mask without changing the unselected bits?

  11. 11

    Which condition correctly tests whether at least one bit selected by mask is set in x?

  12. 12

    Bits 2 through 4 of x must be replaced with the lowest three bits of v. Which expression performs this operation when bit 0 is the least significant bit?

  13. 13

    A permissions value uses READ = 1, WRITE = 2, and EXECUTE = 4. Which decimal value represents READ and EXECUTE together, but not WRITE?

    Question 13
  14. 14

    If bit positions are numbered from 0 at the least significant bit, what decimal value does the mask 1 << 5 represent?

  15. 15

    Assuming two's-complement integers, what is the value of 40 & -40?

  16. 16

    For a positive integer x, what does the expression x & (x - 1) do?

  17. 17

    What is the XOR parity result for the bit sequence 1011011, using 0 for even parity and 1 for odd parity?

    Question 17
  18. 18

    Which expression extracts the lowest four bits of x as a value from 0 through 15?

  19. 19

    The highlighted field occupies bits 3, 4, and 5 of x. Which expression extracts it and moves it to the lowest three bit positions?

    Question 19
  20. 20

    The image shows the 8-bit pattern 10000001 being rotated left by one position. What is the resulting pattern?

    Question 20

Download the App now to have access to + 5000 free courses, exercises, certificates and lots of content without paying anything!

  • 100% free online courses from start to finish

    Thousands of online courses in video, ebooks and audiobooks.

  • More than 60 thousand free exercises

    To test your knowledge during online courses

  • Valid free Digital Certificate with QR Code

    Generated directly from your cell phone's photo gallery and sent to your email

Cursa app on the ebook screen, the video course screen and the course exercises screen, plus the course completion certificate