/* Matrix Sum - Program to find sum of diagonal elements, elements above diagonal and elements below diagonal of a given square matrix */ #include #include void main() { int x[10][10], nr, nc, r, c, sumd=0, suma=0, sumb=0 ; clrscr() ; printf("Enter the number of rows and columns: ") ; scanf("%d %d", &nr, &nc) ; printf("Enter elements of the matrix row-wise: \n") ; for(r=0 ; rc) sumb = sumb + x[r][c] ; } printf("The sum of all diagonal elements is %d \n", sumd) ; printf("The sum of elements above diagonal is %d \n", suma) ; printf("The sum of elements below diagonal is %d \n", sumb) ; getch() ; } /* The following logic is also correct for(r=0 ; r