ProgrammingHardTCS NQT · Infosys

What is printed? Assume uint8t is 8 bits.

What is printed? Assume uint8_t is 8 bits.
#include <stdint.h>
#include <stdio.h>
int main(void) {
    uint8_t acc = 0;
    uint8_t v[] = {200, 100, 50, 10};
    for (int i = 0; i < 4; i++)
        acc += v[i];
    printf("%d", acc);
}
  1. A. 360
  2. B. 104
  3. C. 88
  4. D. 0

Correct answer: B. 104

The running sum wraps modulo 256 at each addition, and the final value is 360 mod 256 = 104.

More C Programming questions

Exams that ask this topic