GATE Computer ScienceHardGATE CS (PYQ pattern)
char *n[] = {"delhi", "mumbai", "chennai", "kolkata"}; char **pp = n; ++pp; printf("%s ", *pp + 2); printf("%c ", **++pp); printf("%s ", pp[-1] + 3); printf("%c", *(*(pp + 1) + 4) + 1); What is printed?
- A. mbai m bai b
- B. mbai c nnai b
- C. mbai c bai b
- D. mbai c bai a
Correct answer: C. mbai c bai b
After ++pp, pp points to "mumbai", so *pp + 2 is "mbai". **++pp first moves pp to "chennai" and prints 'c'. pp[-1] is "mumbai" again, and + 3 gives "bai". *(pp + 1) is "kolkata"; its character at index 4 is 'a', and 'a' + 1 = 'b' is printed with %c. Each side effect is in its own statement, so the output is fully defined: mbai c bai b.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- 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…
- Binary search (lo = 0, hi = n - 1, mid = (lo + hi) / 2 with integer division) is run on a sorted array of the 100 elements 1..100 once for…