Hi i'm currently working on trying to create a concentric magic square for an array of size n.

So far what i have done in my method was determine the smalles magic square i can generate.

i.e if n is even the smallest magic square i can make is is a 4 x4
and if n is odd a 3 x 3

however i'm having trouble to copy the elements of the smallest magic square into the nxn array.


For example give a n=7

i have generated the 3x3 magic square:
8 1 6
3 5 7
4 9 2

and i want to place this magis square in the middle of the 7 x 7 array as follows

0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 8 1 6 0 0
0 0 3 5 7 0 0
0 0 4 9 2 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0

here is the snippet of my code for it:
Code:
for(i=m/2-1;i<n+2;i++) {
          for(j=m/2-1;j<n+2;j++) Magic[i][j]=innerMagic[i-2][j-2];
          
          }
it works fine for n=7 but doesn't for all other cases.

Can someone please help me here.

Please go easy on me. I'm new to C programming