```
int solve(int a[])
{
int index,i;
index=find_index(a);
if(index==101)
{
return 1;
}
if(index!=101)
{
for(i=1;i<=9;i++)
{
if(cheak_coll(a,i,index)==1 && cheak_grid(a,i,index)==1 && cheak_row(a,i,index)==1)
{
a[index]=i;
if(solve(a))
{
return 1;
}
a[index]=0;
}
}
}
else
{
return 1;
}
return 0;
}
```

In given example what is different between `return 1`

and `return 0`

?

I us `int fun()`

in place `bool fun()`

.In bool function return true and return false are same as `return 1`

and `return 0`

?

And how backtracking work in this code?

Tanks in advance..

# Best How To :

In given example what is different between return 1 and return 0?

Judging by the following block code

```
if(solve(a))
{
return 1;
}
```

it seems that a return value of `0`

indicates not solved yet and a return value `1`

indicates solved.

I us `int fun()`

in place `bool fun()`

. In bool function `return true`

and `return false`

are same as `return 1`

and `return 0`

?

Yes.

And how backtracking work in this code?

I don't know.

The function is a bit sloppy. You have the block:

```
if(index==101)
{
return 1;
}
```

If `index`

is equal to `101`

, the function will return. If it is not, it will go to the next statement. Hence the statement:

```
if ( index != 101 )
```

is redundant. The corresponding `else`

will never be exercised since the function would have already returned `if ( index == 101 )`

.

The function can be simplified to:

```
int solve(int a[])
{
int index,i;
index=find_index(a);
if(index==101)
{
return 1;
}
for(i=1;i<=9;i++)
{
if(cheak_coll(a,i,index)==1 && cheak_grid(a,i,index)==1 && cheak_row(a,i,index)==1)
{
a[index]=i;
if(solve(a))
{
return 1;
}
a[index]=0;
}
}
return 0;
}
```

I hope the simplified version makes it easier for you to figure out how the backtracking works for your problem.