Write a C program to read elements in a matrix and find the sum of main diagonal (major diagonal) elements of matrix. Find sum of all elements of main diagonal of a matrix. Logic to find sum of main diagonal elements of a matrix in C programming.
Example
Input
Input array elements: 1 2 3 4 5 6 7 8 9
Output
Sum of main diagonal elements = 15