Home » Debates

i[3] or 3[i]

Last night a while writing a very basic program in ‘C’ language, I came across something weird. Basically in ‘C’ if you want to display the value of some element in an array it is denoted as i [no. of index], where ‘i’ is name of the array and in square bracket you write the index number, which u want to display.

The mistake I made was I wrote the index_number[name of array] ( Wrote 3[i] instead of i[3] ) and it gave the same result as it should have given, if I had written it  correctly. Check the screenshot shown below.

Code:

Output

code-output

Now I m wondering how does that happen, I mean whatever I have read about ‘C’ programming as yet, says i[3] is the method to access the element at 3rd index, in fact I have not ever came across any notation of the form 3[i], so what’s the issue, have you ever seen this, why does this happen, any idea?

If you want to download this code and see it yourself, here is the file, we have uploaded it for you.

Tagged with: | Need more help ? Ask your Questions in our Community | Follow us on Twitter @TSNW or Facebook
Share on Twitter Share on Facebook Subscribe to Feed Print This Post
Translate to EnglishÜbersetzen Sie zum Deutsch/GermanPreložiť do slovenčiny/SlovakTulkot uz latviešu/LatvianTradueix al català/Catalanहिन्दी अनुवाद करने के लिए/HindiÖversätta till Svensk/SwedishOversetter til Norsk/NorwegianПереведите к русскому/RussianVertaal aan het Nederlands/Dutchترجمة الى العربية/ArabicПереклад на українську/UkrainianTraduzca al Español/SpanishTraduisez au Français/FrenchTraduca ad Italiano/ItalianTraduza ao Português/Portuguese

Author Details

Posted on 9th April 2008 by Manav Mishra , here to write articles about things which are somehow related to computers, internet (and at times, may be, to blogging as well). He wants to make an Identity for himself, he loves, testing new softwares and services which can really help to improve the productivity of individual. All posts by Manav Mishra | Connect with me @ Twitter | Stumble

Leave your response!

Be nice. Keep it clean. Stay on topic. No spam.