Sudoku Solver problem in the code

hey i can able to resolve my error can you help me in resolving
#include
#include
using namespace std;
bool canPlace(int mat[][n],int i,int j,int n,int number){
for(int x=0;x<n;x++){
//Row column check
if(mat[x][j] == number || mat[i][x] == number){
return false;
}
}

int rn =sqrt(n);
int sx = (i/rn)*rn;
int sy = (j/rn)*rn;

for(int x = sx;x<sx+rn;x++){
    for(int y=sy;y<sy+rn;y++){
        if(mat[x][y] == number){
            return false;
        }
    }
}
return true;

}

bool SolveSudoku(int mat[][n],int i,int j,int n){
//base case
if(i==n){
//print the matrix
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cout<<mat[i][j]<<" ";
}
cout<<endl;
}

    return true;
}

//column end 
if(j==n){
    SolveSudoku(mat,i+1,0,n);
}

//skipping the pre-filled cells;

if(mat[i][j] != 0){
    SolveSudoku(mat,i,j+1,n);
}

//recursive case
//placing the number where 0

for(int number=1;i<n;i++){
    if(canPlace(mat,i,j,n,number)){
        
        //assume 
        mat[i][j] = number;
        bool couldPlace = SolveSudoku(mat,i,j+1,n);

        if(couldPlace==true){
            return true;
        }
    }
}

//backtrack 
mat[i][j] = 0;
return false;

}

int main() {
int n;
cin>>n;
cout<<n<<" ";
int mat[n][n];

for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
		cin>>mat[i][j];
	}
}

//call SolveSudoku functio
SolveSudoku(mat,0,0,n);

return 0;

}

I have edited your code, try to submit now,

if i want to solve a sudoku of n = 18 then should it work ??
I am not get the solution well plz if you mark why you do that change in my code it will be helpful.

This is only for 9x9 matrix only… You can try for 18x18 input as well, I only changed the matrix as mat[9][9], wherever it is present in your code, and also I have changed these in your code, as you forget to write return before making recursive calls…
if(j==n){
return SolveSudoku(mat,i+1,0,n);
}
if(mat[i][j] != 0){
return SolveSudoku(mat,i,j+1,n);
}

Rest code was alright…