Prepare for the A Level Computer Science OCR Exam with engaging quiz questions and interactive flashcards. Get ready to excel in your exam with comprehensive study materials designed to bolster your knowledge and confidence.

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

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.