GATE Computer ScienceEasyGATE CS (PYQ pattern)
int a[] = {2, 4, 6, 8, 10}; int *p = a + 1, *q = a + 4; printf("%d %d %d", *p + *q, *(q - 2), q - p); What is printed?
- A. 14 6 3
- B. 14 6 12
- C. 6 6 3
- D. 14 4 3
Correct answer: A. 14 6 3
*p = 4 and *q = 10 give 14; q - 2 points to a[2] = 6; q - p is the element difference 3, not a byte count.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- int f(void) { static int c = 0; return ++c; } int main() { int x = f() || f(); int y = f() && f() > 3 ? f() : -f(); printf("%d %d %d", x…
- In a min-heap stored 1-indexed in an array with children of i at 2i and 2i+1, a node at index 77 is replaced by a smaller key and sifted…
- int a[] = {5, 3, 8, 4, 2, 9, 1, 7, 6, 10}; int st[10], top = -1, nge[10]; for (int i = 0; i < 10; i++) nge[i] = -1; for (int i = 0; i <…
- A min-stack keeps an auxiliary stack: a value is pushed on it when it is less than or equal to the current auxiliary top (or it is empty)…
- for (i = 1; i < 1000; i = 2) for (j = 0; j < i; j++) cnt++; What is the final value of cnt (starting from 0)?
- A table of size 11 uses linear probing with h(k) = k mod 11 and tombstones: a deleted slot is marked DELETED; search continues past…