Getting wrong output

#include
using namespace std;
bool isSafe(int board[][10],int i,int j,int n)
{
//Check for col
for(int row=0;row<i;row++)
{
if(board[row][j]==1)
{
return false;
}
}
//Check for left diagonal
int x=i;
int y=j;
while(x>=0 && y>=0)
{
if(board[x][j]==1)
{
return false;
}
x–;
j–;
}
//Check for right diagnol
x=i;
y=j;
while(x>=0 && y<n)
{
if(board[x][y]==1)
{
return false;
}
x–;
y++;
}
return true;
}
bool solveQueen(int board[][10],int i,int n)
{
if(i==n)
{
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(board[i][j]==1)
{
cout<<"Q “;
}
else
{
cout<<”_ ";
}
}
cout<<endl;
}
return true;
}
//Recursive Case
for(int j=0;j<n;j++)
{
if(isSafe(board,i,j,n))
{
//Place the queen
board[i][j]=1;
bool nextQueenRakhPaye=solveQueen(board,i+1,n);
if(nextQueenRakhPaye==1)
{
return true;
}
//Backtrack bcox i,j is not the right position
board[i][j]=0;
}
}
return false;

}
int main() {
int n;
cin>>n;
int board[10][10]={0};
solveQueen(board,0,n);
return 0;
}
sir i m getting wrong output.Please debug this code.

in the isSafe function, simply checking for diagonals is a blunder since there is no check for the matrix indices going out of bound, kindly fix that.

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.