Hi. I'm a statistics student and I've got a C Programming makup exam upcoming, tomorrow actually. Professor asked this one in the last exam, and I wanted to redo it, but it doesn't work properly. The only problem is actually the sum isn't calculated properly. I'd appreciate some help.

Ps: Texts are in Turkish, and here are their meanings:
Matrisin satir ve sutun sayisini giriniz: Enter the row and column number of the matrix
Matrisin elemanlarini giriniz: Enter the elements of the matrix
Matris asagidaki gibidir: The matrix is as shown below
Kosegenlerin toplami: Sum of the diagonal elements of matrix/images/forum/upload/2015-06-24/ccf2788be5f5aef3b6ca41f331de9481.jpg