ProgrammingHard
int a = 7; int b = a++ * 2; printf("%d %d", a, b); What is printed?
- A. 8 14
- B. 7 14
- C. 8 16
- D. 7 7
Correct answer: A. 8 14
The post-increment uses the old value 7 in the multiplication, so b is 14, and a is incremented to 8.
More C Programming questions
- int i = 3; int j = i-- - --i; printf("%d %d", i, j); What is printed?
- 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?