Computer Science, asked by 8967163799, 4 months ago

Write a Algorithm and C program to add diagonal elements in matrix​

Answers

Answered by AquariusCyborg
0

Answer:

Explanation:

This C program is to find the sum of diagonal elements of a square matrix. ...

1 2.

3 4.

Sum = 1+4 = 5.

1st iteration for(i=0;i<row;i++) i.e. for(i=0;0<2;i++) Outer loop.

1st iteration for(j=0;j<col;j++) i.e. for(j=0;0<2;j++) Inner loop.

if(i==j) i.e. if(0==0) true.

sum=sum+mat[i][j]; i.e. sum=0+mat[0][0] i.e. sum=0+1 i.e. sum=1.

Similar questions