ProgrammingHardGATE CS · Campus placements
int m[2][2] = {{1, 2}, {3, 4}}; int (*r)[2] = m; What is r[1][0] + *(r[0] + 1)?
- A. 5
- B. 4
- C. 6
- D. 3
Correct answer: A. 5
r[1][0] is m[1][0] = 3, and *(r[0] + 1) is m[0][1] = 2, so the sum is 5. The row pointer r[0] decays to int *, so the second term is one element into row 0.
More C Programming questions
- uint32t n = 100000u; uint32t t = n (n + 1) / 2; What is t?
- int x = 0; for (int i = 0; i < 5; i++) x = x ^ i << 1; What is x at the end?
- uint16t a = 300, b = 300; uint16t p = a b; What is p?
- What does printf("%d", strcmp("apple", "Apple") > 0) print?
- A stair can be climbed by 1, 2 or 3 steps. How many ways are there to climb 4 stairs?
- #define N 3 and int a[N 2 + 1]; What is sizeof a / sizeof a[0]?