What is the output of the following C code snippet?

2017

What is the output of the following C code snippet?

image.png

Answer: D. 0In 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…

  1. A.

    Compile time error

  2. B.

    15

  3. C.

    45

  4. 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.

Explore the full course: Isro

Loading lesson…