DATA STRUCTURE
Programming and Technical
Programming
Output
why index is starting with 0???
Read Solution (Total 3)
-
- because of binary representation.if we start a[0] ..then for 8 number we requierd only a[0 to 7]/whoes binary representation is in 3 bit only..like 000,001,010,........111,but for 8 its 1000..it is 4 bit....and take more memory..more ram at excution time
- 9 years agoHelpfull: Yes(10) No(0)
- There can be many reasons stated , But one can be It depends on the compiler and Language that is used like c or c++. And also when an array is called it is created ,e g: int sample[0] is actually abbreviated as *(sample+0) and so on....... for more details please go through this article:http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF
- 10 years agoHelpfull: Yes(2) No(2)
- The first element is at the start of the array so there is no distance. Therefore the offset is 0. The reasons are not just historical: C and C++ are still around and widely used and pointer arithmetic is a very valid reason for having arrays start at index 0.
- 9 years agoHelpfull: Yes(1) No(0)
DATA STRUCTURE Other Question