finished matrix.c to implement magic square