ProgrammingVery hardTCS NQT · C · Advanced
What is printed?
What is printed?
int m[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int (*p)[3] = m + 1;
printf("%d %d %d", (*p)[2], p[1][0], (*(p - 1))[1]);- A. 6 7 5
- B. 3 7 2
- C. 6 7 2
- D. 5 7 2
Correct answer: C. 6 7 2
p points at row 1; (*p)[2] = m[1][2] = 6, p[1][0] = m[2][0] = 7, and (*(p-1))[1] = m[0][1] = 2.
More C Programming questions
- What is printed? c int a[] = {5, 10, 15, 20}; int p = a; p++ += 3; (p)++; ++p; ++p = 2; printf("%d %d %d %d %d", a[0], a[1], a[2], a[3]…
- What is printed? c unsigned char a = 250, b = 10; printf("%d %d", (a + b) > 255, (unsigned char)(a + b));
- What is printed? c uint8t x = 0xA5; x = (x << 4) | (x >> 4); printf("%d %d", x, (uint8t)~x);
- What is printed? c int add(int a, int b) { return a + b; } int sub(int a, int b) { return a - b; } int mul(int a, int b) { return a b; }…
- What is printed? c struct N { int v; struct N nx; }; int main(void) { struct N c = {3, 0}, b = {2, &c}, a = {1, &b}; struct N p = &a…
- What is printed? Assume C99 or later. c int g(int a, int b) { return b ? g(b, a % b) : a; } int main(void) { printf("%d %d", g(-48, 18)…