What is the output of the following C code snippet?
2017
What is the output of the following C code snippet?

Answer: D. 0 — In C, array indexing is defined as pointer arithmetic: a[b] is the same as *(a + b), and b[a] is also valid. Therefore 5[y] accesses y[5], giving 0 for the…
- A.
Compile time error
- B.
15
- C.
45
- D.
0
Attempted by 206 students.
Show answer & explanation
Correct answer: D
In C, array indexing is defined as pointer arithmetic: a[b] is the same as *(a + b), and b[a] is also valid. Therefore 5[y] accesses y[5], giving 0 for the shown array.
Loading lesson…