ProgrammingVery hard
int i = 3; int j = i-- - --i; printf("%d %d", i, j); What is printed?
- A. 1 2
- B. undefined behaviour, because i is modified twice without a sequence point
- C. 2 1
- D. 1 1
Correct answer: B. undefined behaviour, because i is modified twice without a sequence point
The two modifications of i are unsequenced relative to each other, so the program has undefined behaviour and no output can be relied on.
More C Programming questions
- int a[] = {4, 5, 6}; int p = a + 1; printf("%d %d", p, p[1]); What is printed?
- int a[] = {4, 5, 6}; int p = &a[2]; printf("%d", (p - 2)); What is printed?
- int v = 10; int p = &v; int q = &p; q += 5; printf("%d", v); What is printed?
- printf("%d", sizeof(int[4]) / sizeof(int)); What is printed with 4-byte int?
- printf("%d", (int)(0.1 + 0.2 == 0.3)); What is printed in IEEE double arithmetic?
- printf("%d", 'a' < 'b' && 'b' < 'c'); What is printed?