Prepare for the A Level Computer Science OCR Exam with engaging quizzes, detailed explanations, and effective study tips. Maximize your readiness and boost your confidence for exam day!

Practice this question and more.


What is the starting index for arrays in most programming languages?

  1. 1

  2. 0

  3. -1

  4. Both 0 and 1

The correct answer is: 0

In most programming languages, such as C, C++, Java, and Python, the starting index for arrays is 0. This zero-based indexing means that the first element of the array is accessed with index 0, the second element with index 1, and so on. This approach aligns well with low-level memory addressing, where the index represents the offset from the starting address of the array in memory. This design choice can lead to more efficient calculations when iterating through an array because the index directly corresponds to the memory location of each element, allowing simpler arithmetic operations. Languages that employ zero-based indexing generally do so for consistency and performance reasons, making it the most common practice across modern programming languages.