Your code is a little bit messy, for instance, why do you need an anonymous code block line 32 to line 34?
To calculate the sum of rows and columns, you basically need to keep two counter-arrays, rowsum[] and colsum[]:
1 2 3 4 5 6 7 8
for (size_t x=0; x<array_size; ++x) //this loop goes over the rows, "vertically"
{
for (size_t y=0; y<array_size; ++y) //this loop goes over the columns (within the current row), "horizontally"
{
rowsum[x] += array[x][y];
colsum[y] += array[x][y];
}
}
Note that this supposes that rows and columns are the same size, but since it's a square that should be safe to assume.
Hope that helps, please do let us know if you have any further questions.