Discussion
The program fragment
int i = 263 ;
putchar (i) ;
prints
Answer: C
Correct answer: rings the bell
putchar takes an int but converts it to unsigned char before writing, so only the low-order byte survives:
\[ 263 \bmod 256 = 7 \]
Character code 7 is BEL, the alert character, so the terminal sounds its bell rather than printing anything. The lesson is general: passing a value outside the range of unsigned char to putchar is not an error but a silent truncation, and the character actually written is whatever the low byte encodes.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development