+ 1

Is there a specific reason for arrays to start at 0?

Why is it that arrays always start at 0? Is there a specific reason?

25th May 2017, 4:55 PM
Djracem
3 ответов
+ 2
Because the first address where the array starts in memory is where is the element is. So if you take the address of the whole array + 0, you get the first element stored in the array.
25th May 2017, 5:09 PM
aklex
aklex - avatar
0
Well, kinda. The usual names for the states a single bit can have are usually called 0 and 1. So 0 is the smallest possible value. There are programming languages that start at 1 though.
25th May 2017, 5:06 PM
1of3
1of3 - avatar
- 2
In programming zero doesn't mean nothing, it's a value . NULL is nothing .
25th May 2017, 5:25 PM
Bahhaⵣ
Bahhaⵣ - avatar