Presentation is loading. Please wait.

Presentation is loading. Please wait.

Two-Dimensional Arrays

Similar presentations


Presentation on theme: "Two-Dimensional Arrays"— Presentation transcript:

1 Two-Dimensional Arrays
Robert Reaves

2 Two-Dimensional Array
Used to represent items in a table with rows and columns, of the same data type. Good for representing board games, where the screen is though of as a two-dimensional array. A component in a two-dimensional array is accessed by specifying the row and column indexes of the item. Think of a map!

3

4 Array Declaration DataType ArrayName [ ConstIntExpression ] [ ConstIntExpression ]; Example: const int NUM_ROWS = 100; const int NUM_COLS = 9; float alpha [NUM_ROWS][NUM_COLS];

5 Array Access To access an individual component of an array, two expressions are used to specify its position. Array Component Access ArrayName [ IndexExpression ] [ IndexExpression ]; Example: alpha[0][5] = 36.4;


Download ppt "Two-Dimensional Arrays"

Similar presentations


Ads by Google