Creating the sumarray of matrix

can we go row wise and then column wise or vise versa eitherway??

Yes you can go either ways