Why do people count from 0 in computer science? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why do people count from 0 in computer science?

23rd May 2021, 5:56 PM
Devdip Mallick
Devdip Mallick - avatar
4 Answers
+ 2
not in all languages but in most of them indices start at zero because mathematematically it make sense, when computing the address of an array element... item 0 (first) is at same adress than array address, item 1 (second) is at array address + length of items type... so any index address could be computed as: array_address+(index*length_of_items_type) ^^
23rd May 2021, 6:13 PM
visph
visph - avatar
+ 1
Devdip Mallick What do you mean by "count from 0"? Everything start from 0. Are you taking about index start from 0?
23rd May 2021, 6:03 PM
A͢J
A͢J - avatar
+ 1
Pointer https://www.sololearn.com/learn/C/2962/ Visph explains it well.
23rd May 2021, 6:28 PM
Gordon
Gordon - avatar
23rd May 2021, 8:09 PM
Apongpoh Gilbert
Apongpoh Gilbert - avatar