Skip to main content

Posts

Showing posts from June, 2021

why array [0]

Have you ever wondered why do we have to use zero-based indexing in the arrays of programming languages? Okay, so if you are a programmer already, cool. But for the ones who aren’t, it is basically a convention which says, numbering of a sequence starts from zero and not one. Easy right? This thing is mostly used in CS. So if you’re saying that the first alphabet in a string (word), say your name, is A, then in the computer’s language you would say, it’s the zeroth in that string. We call it the, ‘index’ zero. Now, a string or a word is an “array” of alphabets. What’s the array thing? Read ahead. Array is when you store an ordered data or a sequence, one after another, i.e. in continuous locations, in a computer or even in real life. Like in an attendance sheet, you’ll find roll no. two’s name, just in the next line after roll no. one. Here on, it is better if you’ve typed something like this before, ‘array_name[5]’ and even better if you have at least heard about “pointers”. The overw...