Computer Science – 10.2 Arrays | e-Consult
10.2 Arrays (1 questions)
An array is a contiguous block of memory locations used to store a collection of elements of the same data type. The key characteristic of an array is that each element can be accessed using a numerical index. An element refers to a single value stored within the array at a specific index.
The significance of the index is that it provides a way to uniquely identify and access each element within the array. Indices typically start from 0 in most programming languages (zero-based indexing). The element at index 'i' is accessed using the array name followed by the index in square brackets (e.g., myArray[i]).
Example: Consider an array of integers representing the scores of five students: {85, 92, 78, 95, 88}. Here, each number (85, 92, 78, 95, 88) is an element. The index associated with each element is: 0, 1, 2, 3, and 4, respectively. So, scores[0] would access the score 85, scores[1] would access 92, and so on.