Your condition is if(abs(a[i][j])>max), so it looks like you’re comparing the magnitude.  On the next line, you assign max=a[i][j], which will store a negative number.  The next iteration will replace this.
What you want to store is
max = abs(a[i][j]);
1
solved abs function is not giving right answer in c++? [closed]