Computer Science – Arrays | e-Consult
Arrays (1 questions)
An array is a data structure that stores a collection of elements of the same data type in contiguous memory locations. It's essentially a named sequence of variables. Arrays are useful because they allow us to store and access multiple values of the same type using a single variable name and an index. This makes it much more efficient than using separate variables for each value.
For example, consider a program that needs to store the scores of 10 students in a test. If we used 10 individual variables (e.g., score1, score2, ... score10), the code would be verbose and difficult to manage. Using an array (e.g., scores[10]) would be much cleaner and more efficient. We can easily access each student's score using the array index (e.g., scores[0] for the first student's score).