Arrays 109
double x[10];
double w[10];
double z[2][10];
const int N = 5;
m = arraycol(x, 2.0, 11.0, 2.0);
m = arraycol(w, 1.0, 9.0, 2.0);
for(j = 0; j < N; j++) {
z[0][j] = x[i];
z[1][j] = w[i];
}
To access individual elements of a two dimensional array, two indexes are used.
The first number is the index for rows and the second number is the index for
columns. To access the value of the element in array z defined previously at row
1 and column 3, the syntax is: z[1][3]. For example:
zz = z[1][3] + 13.5;
The following lines of C code declare a two-dimensional array named rainf with
size 3 rows and 6 columns, and assign the value 2.4 to every element of the array.
const int COLS = 6;
const int ROWS = 3;
double rainf[ROWS][COLS];
for (j = 1; j < COLS; j++)
for (i