< previous page page_599 next page >

Page 599
In the first statement, 5 is stored into an array component. If counter is 0, 5 is stored into the first component of the array. If counter is 1, 5 is stored into the second place in the array, and so forth.
In the second statement, an array component is selected by the expression number+1. The specific array component accessed is divided by 10 and checked to see if the remainder is nonzero. If number+1 is 0, the value in the first component is being tested; if number+1 is 1, the second place is tested; and so on. Figure 11-5 shows the indexing expression as a constant, a variable, and a more complex expression.
Out-of-Bounds Array Indices
Given the declaration
float alpha[100];
the valid range of index values is 0 through 99. What happens if we execute the statement
alpha[i] = 62.4;
0599-01.gif
Figure 11-5
An Index as a Constant, a Variable, and an Arbitrary Expression

 
< previous page page_599 next page >