Problem Solving: 2-D Matrix Diagonals Sums

Learn how multi-dimensional arrays can be used in different operations.

Diagonal by diagonal sum

Write a program that does the following:

  1. Load the matrix.
  2. Calculate the sum of each diagonal.
  3. Save each diagonal sum of the 2-D matrix to a 1-D array.
  4. Display each diagonal sum.

For example, let’s take We have the following matrix and compute the sum of each diagonal.

Get hands-on with 1200+ tech skills courses.