ProgrammingHardTCS NQT · Infosys
int x = 1, y = 2, z = 3; int *ptrs[3] = {&x, &y, &z}; What is *ptrs[1] + *ptrs[2]?
- A. 3
- B. 4
- C. 5
- D. 6
Correct answer: C. 5
ptrs[1] points to y and ptrs[2] points to z, so the sum is 2 + 3 = 5. Arrays of pointers store addresses, not values.
More C Programming questions
- printf("%d", 0x7FFFFFFF == 2147483647); What is printed?
- unsigned char c = 0xFF; unsigned int u = c << 8 | c; printf("%X", u); What is printed?
- static int total = 0; int add(int n) { static int t = 0; t += n; return t; } Calls add(3), add(4) and add(5) in that order. What does the…
- int r = 0; switch (2) { case 1: r += 1; case 2: r += 10; case 3: r += 100; break; default: r += 1000; } What is r?
- for (int i = 0, j = 10; i < j; i += 3, j -= 3) count++; How many times does the body run?
- int n = 5; int r = n++ 2; What are the final values of r and n?