C program to add the diagonal elements of a matrix

C program to add the diagonal elements of a matrix

Output:

Enter the elements of the 3x3 array:
1 2 3
4 5 6
7 8 9
The sum of the diagonal elements is 15

Implementation: