For those who are failing at test case 21


#1

just check condition
if(upperrow==downrow&&leftcol==rightcol)
c[upperrow][leftcol]=A*A;


#2

Thanks baljot, it really worked !!