In this section, you will learn how to find the sum of diagonals of a matrix in C Program.
In this section, you will learn how to find the sum of diagonals of a matrix in C Program.In this section, you will learn how to determine the sum of both the diagonal of 3X3 matrix. For this, we have declared an array of integers and using the for loops, we have determined the sum of both the diagonals.
Here is the code:
#include <stdio.h> void main() { |
Output:
1 2 6 3 8 5 5 6 7 Sum of First diagonal=16 Sum of Second diagonal=19 |