ProgrammingVery hard
On a platform with 4-byte int, int i = 5; printf("%zu %d", sizeof(i++), i); What is printed?
- A. 4 6
- B. 4 5
- C. 8 5
- D. 4 4
Correct answer: B. 4 5
sizeof does not evaluate its operand, so i stays 5. The size of an int on a typical platform is 4 bytes.
More C Programming questions
- int n = 3; int p = &n; printf("%d", p p + p); What is printed?
- int m[2][2] = {{1, 2}, {3, 4}}; int p = &m[0][0]; printf("%d", p[2] p[1]); What is printed?
- unsigned char c = 255; c++; printf("%d", c); What is printed?
- 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?