ProgrammingHardTCS NQT · Accenture

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 a = 5, b = 10;
    uint8_t d = a - b;
    printf("%d", d);
}
  1. A. 251
  2. B. 250
  3. C. 5
  4. D. 255

Correct answer: A. 251

a - b is -5 as an int, and converting it to uint8_t gives 256 - 5 = 251.

More C Programming questions

Exams that ask this topic