C Program to Find Sum of Diagonal Elements of a Matrix (Matrix के Diagonal Elements का योग ज्ञात करने का C प्रोग्राम)
The diagonal elements of a square matrix are the elements whose row and column indices are equal. In this program, we calculate the sum of the main diagonal elements of a 3×3 matrix. Square Matrix के मुख्य विकर्ण (Main Diagonal) के वे तत्व होते हैं जिनके Row और Column Index समान होते हैं। इस प्रोग्राम में हम 3×3 Matrix के मुख्य विकर्ण के तत्वों का योग ज्ञात करेंगे। C Program #include <stdio.h> #define R 3 #define C 3 int main() { int a[R][C], sum = 0; int i, j; printf("Enter elements of a Matrix:\n"); for (i = 0; i < R; i++) { for (j = 0; j < C; j++) { printf("Enter A[%d][%d] = ", i, j); scanf("%d", &a[i][j]); } } /* Sum of main diagonal elements */ for (i = 0; i < R; i++) { for (j = 0; j < C; j++) { if (i == j) { sum = sum + a[i][j]; } } } printf("\nSum of diagona...