diff --git a/Matrix_programs/Diagnol_sum_of_matrix_elements.c b/Matrix_programs/Diagnol_sum_of_matrix_elements.c new file mode 100644 index 0000000..5e4d797 --- /dev/null +++ b/Matrix_programs/Diagnol_sum_of_matrix_elements.c @@ -0,0 +1,84 @@ +/* +Find sum of left and right diagonals of a matrix : +--------------------------------------- +Input the size of the square matrix : 4 +Input elements of matrix : +2 +4 +3 +4 +2 +5 +7 +5 +8 +9 +3 +5 +8 +9 +5 +1 +The matrix is : + 2 4 3 4 + 2 5 7 5 + 8 9 3 5 + 8 9 5 1 +Addition of the Right Diagonal elements is :11 +Addition of the left Diagonal elements is :28 +*/ +#include +void main() + { + int i,j,a[50][50],sum=0,n,m=0,sum1; + + printf("\n\nFind sum of left and right diagonals of a matrix :\n"); + printf("---------------------------------------\n"); + + printf("Input the size of the square matrix : "); + scanf("%d", &n); + m=n; + printf("Input elements of matrix :\n"); + for(i=0;i