< previous page page_597 next page >

Page 597
0597-01.gif
Figure 11-3
angle and testScore Arrays
which component to access. The syntax template for accessing an array component is
0597-02.gif
The index expression may be as simple as a constant or a variable name or as complex as a combination of variables, operators, and function calls. Whatever the form of the expression, it must result in an integer value. Index expressions can be of type char, short, int, long, or enumeration types because these are all integral types.
The simplest form of index expression is a constant. Using our angle array, the sequence of assignment statements
angle[0] = 4.93;
angle[1] = -15.2;
angle[2] = 0.5;
angle[3] = 1.67;
fills the array components one at a time (see Figure 11-4).
Each array component-angle[2], for instance-can be treated exactly the same as a simple variable. We can assign it a value
angle[2] = 9.6;

 
< previous page page_597 next page >