ProgrammingVery hard
int i = 0; printf("%d %d", i++, i); What does this code do?
- A. It prints 0 1
- B. Undefined behaviour, since i is modified and read without a sequence point
- C. It prints 1 1
- D. It prints 0 0
Correct answer: B. Undefined behaviour, since i is modified and read without a sequence point
The two arguments are unsequenced relative to each other, and i is modified and read without a sequence point. This is undefined behaviour, so it should not be used as a test.
More C Programming questions
- 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?
- What is printed? c #include <stdint.h> #include <stdio.h> int main(void) { uint8t a[] = {200, 100, 50}; uint32t s = 0; uint8t t = 0; for…