ProgrammingModerateProduct-company MCQ pattern
What is printed?
What is printed?
int a[2][3] = {{1, 2, 3}, {4, 5, 6}};
printf("%d %d %d", *(*(a + 1) + 2), *(a[1] + 1), **a + 1);- A. 6 5 2
- B. 6 5 4
- C. 3 5 2
- D. 5 6 2
Correct answer: A. 6 5 2
a + 1 points to row 1, *(a + 1) is that row (decays to &a[1][0]), + 2 then * gives a[1][2] = 6. a[1] + 1 → a[1][1] = 5. **a is a[0][0] = 1, and + 1 applies after dereferencing → 2 (not a[0][1] or a[1][0]).
More C Programming questions
- What is printed? c char s[] = "hello"; char p = s; printf("%zu %zu %zu", strlen(s), sizeof(s), sizeof(p)); / 64-bit system /
- What is printed? c int i = 10, c = 0; do { c++; i++; } while (i < 5); printf("%d %d", i, c);
- What is printed? c int i, j, s = 0; for (i = 0, j = 10; i < j; i += 2, j--) s += j - i; printf("%d %d %d", i, j, s);
- What is printed? c unsigned int u = -16; / 32-bit unsigned int / printf("%d %u %d", 1 << 4, u >> 28, -16 / 4);
- What is printed? c int a = 5, b, c; b = a > 3 ? 10 : 20; c = (b == 10) ? a + b : 0; printf("%d %d %d", a, b, c);
- What is printed? c struct A { char c; int i; char d; }; struct B { int i; double d; }; struct C { char c; double d; char e; }; printf("%zu…