I'm using brute force algo.

here PossValue() tells whether the number N can be place or not.

It returns 1 if it can be placed.. it returns 0 if it can't

- What I tried to do here is...

go to an empty cell (I took 0 as i/p for empty ) and place a possible value N.

then go to next empty cell and do it..

if there exists a cell that can't take any value from 1-9 then go back to previous cell and choose another possible value ( this I did by incrementing from where I stopped..)..

This is my code..

when I compile and provided i/p its not doing nothing.. neither displaying o/p nor showing error not getting into infinite loop..

Code:

// initial value of K is 0
for (i=0; i<9; i++)
{ printf("?");
for (j=0; j<9; j++)
{
if (sudoku[i][j] == 0)
{ printf("(%d,%d)",i,j);
for (n=1+k; n<10; n++)
{
flag1 = 0;
if ( PossValue(i,j,n) == 1 )
{
sudoku[i][j] = n;
break;
}
else if (PossValue(i,j,n) == 0)
{
flag1 = 1;
}
}
}
if (flag1 == 1)
{
if(j >= 1)
{
j = j-1;
k = sudoku[i][j];
}
else if (j=0)
{
i = i-1;
j = 8;
k = sudoku[i][j];
}
}
}
}