ProgrammingHardGATE CS · TCS NQT
What does this C program print? int a[2][3] = {{1,2,3},{4,5,6}}; int (*p)[3] = a; printf("%d %d", (*(p+1))[1], **(p+1) + *(*p+2));
- A. 4 7
- B. 5 6
- C. 5 7
- D. 2 7
Correct answer: C. 5 7
p+1 points to row 1, so (*(p+1))[1] = a[1][1] = 5. **(p+1) = a[1][0] = 4 and *(*p+2) = a[0][2] = 3, so the second value is 7.
More C Programming questions
- What does this C program print? #define SQ(x) xx printf("%d", SQ(2+3) / SQ(1+1));
- What is printed? int f(int n) { static int c = 0; c += n; if (n <= 0) return c; int r = f(n - 1); return r + c; } printf("%d", f(3));
- What does this C program print? unsigned int x = 0xB5; printf("%x", x ^ (x >> 1));
- What is the value of s after this loop? int i, s = 0; for (i = 0; i < 5; i++) { switch (i % 3) { case 0: s += 1; case 1: s += 10; break…
- What is printed? c #include <stdio.h> int main(void) { int a = 0, b = 1, c = 2; int r = (a++ && b++) || (c-- && a--); printf("%d %d %d…
- What is printed? Assume int occupies 4 bytes. c #include <stdio.h> int main(void) { int i = 5; sizet n = sizeof(i++) + sizeof(i = 100)…