Grid Diagonal Sums
PRO1D & 2D Arrays2D Arrays
A 3 x 3 grid of integers is stored in a 2D array. Write a program that inputs 9 integers **row by row** (the first three inputs fill row 1, the next three fill row 2, and so on).
Output two lines:
1. The sum of the main diagonal (top-left to bottom-right).
2. The sum of the anti-diagonal (top-right to bottom-left).
For example, the grid 1 2 3 / 4 5 6 / 7 8 9 has a main diagonal sum of 15 and an anti-diagonal sum of 15.
Example Input
1
2
3
4
5
6
7
8
9
Example Output
15
15
0% (0 passed / 0 attempted)