ProgrammingHardTCS NQT · Infosys

uint8_t acc = 0; uint8_t a[3] = {250, 3, 7}; for each element, acc += a[i]; What is acc after all three additions?

  1. A. 260
  2. B. 0
  3. C. 4
  4. D. 3

Correct answer: C. 4

After 250 and 3 the running value is 253. Adding 7 gives 260, which is stored in uint8_t as 260 mod 256 = 4.

More C Programming questions

Exams that ask this topic