Home Segments Index Top Previous Next

277: Mainline

Consider price, the one-dimensional array of floating-point numbers. To write data into price, you use assignment statements in which the array name and a bracketed integer index appear on the left side of an assignment statement, the place where you are accustomed to seeing variable names. The following expression, for example, inserts a a floating-point number into the place indexed by the value of counter.

 *-- Array's name 
 | 
 |     *-- An integer 
 |     | 
 |     |          *-- Value to be stored 
 |     |          | 
 v     v          v 
price[counter] = 10.2; 

To read data from the price array, once the data have been written, you write an expression containing the array name and a bracketed integer index. The following expression, for example, yields the number stored in the place indexed by the value of counter:

price[counter]