A and B are two unsigned 8-bit numbers such that A + B <= 28. The number of…

2018

A and B are two unsigned 8-bit numbers such that A + B <= 28. The number of possible combinations of A and B is:

  1. A.

    29

  2. B.

    28

  3. C.

    33,151

  4. D.

    24 - 1

Attempted by 427 students.

Show answer & explanation

Correct answer: C

Correct answer: 33,151.

  • For unsigned 8-bit numbers, A and B can each range from 0 to 255.

  • The condition is A + B <= 256. For A = 0 and A = 1, B can take all 256 values.

  • For A = 2 to 255, the number of possible B values is 257 - A. This gives 255 + 254 + ... + 2 values.

  • Total = 256 + 256 + (255 + 254 + ... + 2) = 512 + 32639 = 33151.

Explore the full course: Up Lt Grade Assistant Teacher 2025