I got your magic box program to work. Here's the working version
with a couple of comments to show you what I did. I did some reformatting of your source code because it's the only way I could
debug it. Don't take it personally. If this is one of your first programs you have a good start. Try to cut down on the "else if's".
Code:
#include<stdio.h>
#define SIZE 7
#define RANGE SIZE*SIZE
// changed void main(void) to int main(void)
int main(void)
{
// extra bracketing required here
// see K&R second edition page 111
int square[SIZE][SIZE]={{0}};
int count=1;
int col=SIZE/2;
int row=0;
//build the magic square
do{
count++;
row--;
col++;
if(row == -1 && col == SIZE)
{
row+=2;
col--;
}
else if (row == -1)
row=SIZE-1;
else if(col == SIZE)
col = 0;
else if (square[row][col] != 0)
{
row+=2;
col--;
}
// this line is moved from above
square[row][col] = count;
}while (count < RANGE);
//print magic square
for(row=0;row<SIZE;row++)
{
for(col=0;col<SIZE;col++)
printf("%6d",square[row][col]);
printf("\n");
}
} // end void main(void)