My code do not showing any output

hey @mohit26900
there is a basic error in your code

  1. you have not stored the value returned by function rat_in_maze()

corrected code is -

#include

using namespace std;

bool rat_in_maze(char matrix[5][5],int sol[5][5],int i,int j,int m,int n)

{

if(i==m && j==n)

{

    sol[i][j]=1;

    for(int ii;ii<=m;ii++)

    {

        for(int ji=0;ji<=n;ji++)

        {

            cout<<sol[ii][ji]<<" ";

        }

        cout<<endl;

    }

    return true;

}

if(i>m || j>n)

{

    return false;

}

if(matrix[i][j]=='#')

{

    return false;

}

sol[i][j]=1;

bool rightsuccess=rat_in_maze(matrix,sol,i,j+1,m,n);

bool downsuccess=rat_in_maze(matrix,sol,i+1,j,m,n);

sol[i][j]=0;

if(rightsuccess || downsuccess)

{

    return true;

}

return false;

}

int main() {

char matrix[5][5]={"00#0",

                   "000#",

                   "0000",

                   "0000"};

int sol[5][5] = {0};   

bool flag=rat_in_maze(matrix,sol,0,0,3,3);      

return 0;          

}

if it still does not run try to run the same code on different IDE for eg. www.ideone.com by selecting language as c++14

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

This code is showing segmentation fault on coding blocks ide.

try on different ide maybe there is some issue with CB ide