Exam-style question
Try this first
An 8-bit unsigned integer can store values from 0 to 255. If a program attempts to store the value 256, what is the most likely outcome related to overflow?.
- A.The program will automatically switch to a 16-bit integer.
- B.The value will be accurately stored as 256.
- C.An overflow will occur, potentially storing an incorrect value like 0.
- D.The system will halt all operations and display an error message for 256.
Answer and explanation
Concise answer
An overflow will occur, potentially storing an incorrect value like 0.
Why this is correct
When an 8-bit unsigned integer overflows from 255, the next logical increment, 256, cannot be stored, and often wraps around to 0 or another incorrect value due to truncated bits.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
