int diagonalSum(int** mat, int matSize, int* matColSize){ int row=0,col1=0,col2=(*matColSize)-1,sum=0; while(row<matSize && col1<*matColSize && col2>=0) { sum += (col1 == col2)? mat[row][col1]: mat[row][col1]+mat[row][col2]; row++,col1++,col2--; } return sum; }