Presentations | English
An array is used for collecting data of the same type together into one variable. Although arrays are essentially ordered lists of elements, it can still be appropriate to use an array to store data when the order of the data does not matter. Consider the example of a class of students where you need to store data about all of the students. If this were the problem you had to solve, you may create some data type that held all of the relevant information about any one particular student, such as name and average. Then you would use an array to store a student record for each student in the class. In a case like this, the index of each student is arbitrary; their position in the array means nothing. Instead, you would be benefitting from the the fact that you can loop through the entire array and access the information about each of the students. This might be useful if you were interested in calculating class-wide statistics, such as what the average grade in the class was.
Free
PPTX (57 Slides)
Presentations | English