ProgrammingModerateTCS NQT · Infosys

uint8_t a = 200, b = 100; uint8_t c = a + b; What is the value of c?

  1. A. 300
  2. B. 45
  3. C. 44
  4. D. 0

Correct answer: C. 44

a and b are promoted to int, so a + b is 300. Converting 300 to uint8_t is well defined and reduces it modulo 256, giving 44.

More C Programming questions

Exams that ask this topic