8.1.5 Manipulating 2d Arrays [VERIFIED]

Find the sum of all numbers in the grid.

Because you have two dimensions (rows and columns), you need two loops to traverse the entire structure: 8.1.5 manipulating 2d arrays

[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Find the sum of all numbers in the grid

// Inner loop: iterates through columns in the current row for (int c = 0; c < grid[r].length; c++) System.out.print(grid[r][c] + " "); c++) System.out.print(grid[r][c] + " ")

Fix the column index c and loop through all r . 3. Transforming the Grid Flipping and Reversing

Imagine you are at grid[r][c] .