ProgrammingModerate
unsigned char c = 255; c++; printf("%d", c); What is printed?
- A. 0
- B. 256
- C. 255
- D. -1
Correct answer: A. 0
Incrementing an unsigned char past its maximum wraps to 0, which is well defined.
More C Programming questions
- int i = 0; printf("%d %d", i++, i); What does this code do?
- const char names[] = {"zero", "one", "two"}; printf("%c", names[2][1]); What is printed?
- int x = 0; for (int i = 0; i < 4; i++) x += i % 2 ? i : -i; printf("%d", x); What is printed?
- int x = 10; int p = &x; p += p 2; printf("%d", x); What is printed?
- int a = 5, b = 2; printf("%d %d", a / b, a % b); What is printed?
- int main(void) { int a[] = {1, 2, 3}; printf("%zu", sizeof a / sizeof a[0]); } What is printed?