Home Segments Top Top Previous Next

512: Mainline

To use an array, once it is created, you need to know how to write into and to read from the various locations in the array, each of which is identified by a numerical index.

Consider durations—the one-dimensional array of integers. To write data into that array, you use assignment statements in which the array name and a bracketed integer index appear on the left side of an assignment operator—the place where you are accustomed to seeing variable names. The following statement, for example, inserts an integer into the place indexed by the value assigned to the counter variable:

durations[counter] = 65;