Home Segments Index Top Previous Next

282: Mainline

You easily can define arrays with more than one dimension. Suppose, for example, that you want to store the high, low, and close of the Dow Jones Industrial Average for, say, 100 days. You can easily arrange to define a suitable array with three rows:

     0          1          2              <-- Index, the day 
*----------*----------*----------*-- 
|  3552.2  |  3560.0  |  3540.0  |        <-- High 
*----------*----------*----------*-- 
|  3539.2  |  3544.8  |  3530.6  |        <-- Low 
*----------*----------*----------*--- 
|  3550.5  |  3557.7  |  3530.6  |        <-- Close 
*----------*----------*----------*---- 

To define such an array, you simply include a bracketed dimension size for each dimension. For example, to define a 3 by 100 array of floating-point numbers, each describing a Dow Jones Industrial Average, you write the following statement:

double djia[3][100];