ProgrammingHardGATE CS · Product company OA
What is printed?
What is printed?
int m[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int (*r)[3] = m + 1;
printf("%d %d %d", r[1][0], (*r)[2], **(r - 1) + r[0][1]);- A. 7 6 5
- B. 7 6 6
- C. 7 3 6
- D. 4 6 6
Correct answer: B. 7 6 6
r points to row 1, so r[1] is row 2 and r[1][0] = 7. (*r)[2] is row 1, column 2 = 6. **(r − 1) is m[0][0] = 1 and r[0][1] = m[1][1] = 5, so the sum is 6. '4' treats r as if it still pointed to row 0.
More C Programming questions
- Which of these statements about C's dynamic-memory functions are correct? (i) realloc(NULL, n) behaves like malloc(n). (ii) If realloc…
- Why is the line p = realloc(p, 2 n sizeof p); considered unsafe?
- Given char s[] = "ab"; and the declarations below, for which of p1 to p4 does the statement p = 'x'; compile? c typedef char PC; const PC…
- Assume 32-bit unsigned int. What is printed? c unsigned int u = 1u << 31; printf("%u %u", u >> 31, (u >> 30) | (u >> 28 & 1));
- What is printed? c int x = 5, s = 0; switch (x) { default: s += 1; case 1: s += 10; case 2: s += 100; break; case 3: s += 1000; }…
- What is f in the declaration below? c int ((f)(int))[3];