Find all possible path when all moment is possible


segmentation fault occur plz reply as soon as possible I want to correct my doubt at earliest

int sol[10][10]={0}; does not initialize the entire array with 0, but only the first row.

so how to initialize it???

either iterate and initialize all sol[i][j] = 0, or use

memset(sol, 0, sizeof sol);

if in 25 line of my code i remove sol[i][j]==1 it gives segmentation fault why this happen

Because then you will keep on visiting the same node again and again.
It is necessary mark the nodes that are in the path taken, so that you don’t end up in any kind of cycle.

one more question give me approach to find unique path if there are set of movements are given

How is this different from the original question?
Maybe I don’t get you

unique path type of question when you have some types of restriction in movement of rat that first you move up or down then left or right this types of question

Ohh, then you just return true as soon as you find a path, otherwise you move into the other direction.

same as i apply in above code???

Yes I guess, in case I understand your question correctly!

You are given an N*M grid. Each cell (i,j) in the grid is either blocked, or empty. The rat can move from a position towards left, right, up or down on the grid.
Initially rat is on the position (1,1). It wants to reach position (N,M) where it’s cheese is waiting for. There exits a unique path in the grid . Find that path and help the rat reach its cheese.An ‘X’ in position (i,j) denotes that the cell is blocked and ans ‘O’ denotes that the cell is empty.
in this question what should i do and modify my code accordingly

Your code is correct, it just says that there exists a unique path.

(how your code checked against various testcases)
Technical detail: this is so that it easier to compare your output with the correct output directly. If there were multiple paths then a separate checker had to be run to check if your path is indeed correct

means there is no such typ of unique path typ question if in question 2 direction we have to code in 2 direction

yes, for eg. if the question was only for right and down, then only consider right and down