+ 5
Why are we starting 0 in array?
7 Respostas
+ 4
🌴Vincent Berger🌴 I doubt that anything is converted to hexadecimals in the process because a CPU has no idea what hexadecimals are and what to do with them. Basically, hexadecimals are a more compact way to write binaries. They are made for humans, not for computers. For humans, 0xFACE is easier to interpret than 0b1111101011001110, and a memory address with 10 hexadecimals is easier to handle than its binary representation with 40 digits. That's the only reason hexadecimals are used.
Also, the 0/1 thing is only the most common way to describe the two states of a binary system. You could use off/on, A/B, -/+, low/high, yin/yang etc. as well to describe the same. I don't think that the binary "0" has anything to do with indices of arrays or lists
+ 9
Because 0 is also a number and only programmers appreciated the value of 0. 😅 Also in counting, 0 is always mentioned.
+ 4
thanku for all
+ 2
Morpheus,
Excuse me?
What u mean with that?
+ 2
Morpheus,
I learned that a few years ago.
If my answer is incorrect, explanation would be appericiated👍
+ 2
Simplest answer : Counting starts from 0 in programming instead of 1.
That is why when you create an int array of size 5 but you cannot access its fifth element like this arr[5] that would give an IndexOutOfBound error. This is because the very first index of array we access is like arr[0] so to access the last index we would use arr[4]
- 2
hf