An array is a collection of data storage locations, each having the same data type and the
same name. Each storage location in an array is called an array element.
Why do you need arrays in your programs ? This question can be answered with an example
Figure 3.1 illustrates the difference between using individual variables and an array. If you
are keeping track of your business expenses for the current financial year, and filing your
receipts by month, you could have a separate folder for each monthâ€™s receipts, but it would
be more convenient to have a single folder with twelve compartments. Extend this example
to computer programming. Imagine that you are designing a program to keep track of your
business expense totals. The program could declare twelve separate variables, one for each
monthâ€™s expense total. This approach is analogous to having twelve separate folders for your
receipts. Good programming practice, however, would utilize an array with twelve elements,
storing each monthâ€™s total in the corresponding array element. This approach is comparable
to filing your receipts in a single folder with twelve compartments.