GATE Computer ScienceVery hardGATE CS (PYQ pattern)
int a[4][3] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; int (*p)[3] = a; p += 2; int *q = *p + 1; printf("%d %d %d %d", *(*(p - 1) + 2), (*p)[1], q[-1], p[1][0]); What is printed?
- A. 5 7 6 9
- B. 5 7 7 9
- C. 5 6 6 9
- D. 2 7 6 10
Correct answer: A. 5 7 6 9
p += 2 makes p point to row 2 (values 6, 7, 8). *(*(p-1)+2) = a[1][2] = 5; (*p)[1] = 7; q = &a[2][1] so q[-1] = a[2][0] = 6; p[1][0] = a[3][0] = 9.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- char n[] = {"delhi", "mumbai", "chennai", "kolkata"}; char pp = n; ++pp; printf("%s ", pp + 2); printf("%c ", ++pp); printf("%s ", pp[-1]…
- char src[] = "gate0cse"; char dst[20]; char d = dst, s = src; int n = 0; while ((d++ = s++)) n++; printf("%d %zu %zu", n, sizeof(src)…
- What is the total number of characters written to the output by this program? (Assume arguments of the last printf are evaluated before…
- unsigned char a = 250, b = 10; unsigned char c = a + b; int x = -1; unsigned int y = 1; printf("%d %d %d %d", c, a + b, x < y, (unsigned…
- int s = 0; for (int i = 0; i < 6; i++) { if (i == 1) continue; switch (i % 4) { case 0: s += 1; case 1: s += 10; break; case 2: s += 100…
- A recursive routine place(r) tries every column c for row r, recursing only if column c and both diagonals are free of earlier queens; at…