//------------------------------------------------------------------ // // A program that uses a 2D array // // Simon Parsons // April 30th 2007. // //------------------------------------------------------------------ //------------------------------------------------------------------ // // Link the necessary libraries #include using namespace std; //------------------------------------------------------------------ // // Function prototype void printGrid(int g[][3]); //------------------------------------------------------------------ // // The main method int main() { // Initialisation int grid[2][3] = {{1, 2, 3}, {4, 5, 6}}; printGrid(grid); return 0; } //------------------------------------------------------------------ // // Function definition void printGrid(int g[][3]) { int i, j; for(i = 0; i < 2; i++) { for(j = 0; j < 3; j++) { cout << g[i][j] << endl; } } }