C Quiz – 102 | Question 5
In the context of the below program snippet, pick the best answer.
arr = 123;
Which of the given printf statement(s) would be able to print arr
(A) only (i) would compile and print 123.
(B) both (i) and (ii) would compile and both would print 123.
(C) only (i), (ii) and (iii) would compile but only (i) and (ii) would print 123.
(D) only (i), (ii) and (iii) would compile and all three would print 123.
(E) all (i), (ii), (iii) and (iv) would compile but only (i) and (ii) would print 123.
all (i), (ii), (iii) and (iv) would compile and all would print 123.
Explanation: For arrays, we can convert array subscript operator  to pointer deference operator * with proper offset. It means that arr[x] is equal to *(arr+x). Basically, these two are interchangeable. The same concept can be applied in multi-dimensional arrays as well.
That’s why all of the above 4 printf are referring to the same element i.e. arr
Quiz of this Question
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!