ProgrammingVery hardGATE CS · TCS NQT

What is printed? Assume int is 32 bits.

What is printed? Assume int is 32 bits.
#include <stdint.h>
#include <stdio.h>
int main(void) {
    uint8_t b = (uint8_t)-200;
    printf("%d", b);
}
  1. A. 200
  2. B. 4294967096
  3. C. 56
  4. D. 312

Correct answer: C. 56

Converting -200 to uint8_t gives (-200) mod 256 = 56. The value 312 comes from adding 256 instead of reducing modulo 256 by the correct amount.

More C Programming questions

Exams that ask this topic