Question: Are Expressions arrays[i] and i[arrays] same?
Answer: We know that we can use pointer and indirection to access an array. Let’s try to rewrite the exp.
using pointer as:
*(arrays + i);
which, of course, we can write as:
*(i + arrays); /* addition is 'commutative' */
which we rewrite in subscript form as:
So, these two expressions are same! But writing this way is awkward and one should practice decent style of programming!
Sanfoundry Global Education & Learning Series – 1000 C Tutorials.
Take C Programming Tests Now!
If you wish to look at all C Tutorials, go to C Tutorials.
- Get Free Certificate of Merit in C Programming
- Participate in C Programming Certification Contest
- Become a Top Ranker in C Programming
- Take C Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Watch Advanced C Programming Videos
- Buy C Books
- Practice Computer Science MCQs
- Apply for Computer Science Internship
- Apply for C Internship