Discussion
The value of c after this runs on a target with 32-bit int is
uint8_t a = 200, b = 100; uint8_t c = (a + b) / 2;
Answer: C
Both operands are promoted to int before the addition, so the sum is 300 with no wrap and the division gives 150, which fits in a byte. Had the arithmetic been done in eight bits the sum would have wrapped to 44 and the answer would have been 22.
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