So far I have managed to get diagonal of a matrix only like this, but I know there is a much simpler way, help! I a matrix is big this is useless.

Code:for(a=0;a<3;a++) { for(b=0;b<3;b++) { if(a==0 && b==0) { printf("\n%d", mx[a][b]); } if(a==1 && b==1) { printf("\n%d", mx[a][b]); } if(a==2 && b==2) { printf("\n%d", mx[a][b]); } }