What is wrong? When i uncomment the print statements i get the correct answer for count

CODE:
#include<bits/stdc++.h>
using namespace std;

bool isValid(int n, int a[][11], int i, int j){
for(int k=0; k<i; k++){
if(a[k][j]==1) return false;
}
for(int x=i-1, y=j-1; x>=0 && y>=0; x–, y–){
if(a[x][y]==1) return false;
}
for(int x=i-1, y=j+1; x<n && y<n; x–, y++){
if(a[x][y]==1) return false;
}
return true;
}

void nQueens(int n, int a[][11], int i, int* count){
if(i==n){
*count = *count + 1;
// for(int row=0; row<n; row++){
// for(int column=0; column<n; column++){
// if(a[row][column]==1){
// cout<<ā€œQ ā€œ;
// }else{
// cout<<ā€_ ā€œ;
// }
// }cout<<ā€\nā€;
// }cout<<"\n";
return;
}
for(int j=0; j<n; j++){
if(isValid(n,a,i,j)){
a[i][j]=1;
// for(int row=0; row<n; row++){
// for(int column=0; column<n; column++){
// cout<<a[row][column]<<" ā€œ;
// }cout<<ā€\n";
// }cout<<"\n";
nQueens(n, a, i+1, count);
a[i][j]=0;
}
}
}

int main() {
int n;
int count=0;
cin>>n;
int a[11][11]={0};
nQueens(n,a, 0, &count);
cout<<count;
}

@alien
There are errors in your isValid function. It should be written this way:
bool isValid(int n, int a[][11], int i, int j){
for(int k=0; k<i; k++){
if(a[k][j]==1) return false;
}
for(int x=i-1, y=j-1; x>=0 && y>=0;){
if(a[x][y]==1) return false;
x–; y–;
}
for(int x=i-1, y=j+1; x<n && y<n; ){
if(a[x][y]==1) return false;
x–; y++;
}
return true;
}

you were performing x- and y-. These are absolutely wrong. Check the function above function for the correct way. Also check out the video on n queen with bitmasking to complete the question in an efficient method.

If my solution was able to answer your query, please mark the doubt as resolved.
If you face any difficulty, please feel free to revert.