2079 6

C Programming20795 marksTwo-dimensional arrays

Write a program to find the sum of diagonal elements of n*n matrix.

Write a program to find the sum of diagonal elements of n*n matrix. [5]

For an n×n matrix, there are two diagonals: - Principal (Main) Diagonal: elements where row index == column index → a[i][i] - Secondary (Anti) Diagonal: elements where row + column = n-1 → a[i][n-1-i] Note: If an element lies on both diagonals (center of odd-sized matrix), it should be counted on...

Up nextHow keyword is different from Variables? Discuss Basic data types with its ranges.