Staircase Search Code not working

Please check my code & update the comments in it. what’s wrong?

if(a[i][j]>key){
            j--;       
 }

this is correct one

void StairCaseSearch(int a[][1002],int n,int key){
    int i=0;
    int j=n-1;
    bool Steps=false;
    while(i>=0 && j>=0 && i<n && j<n){
        if(a[i][j]==key){
            Steps=true;
            cout<<"Found at index "<<i<<" and "<<j<<endl;
            return;
        }
        else if(a[i][j]>key){
            j--;        }
        else{
            i++;
        }
    }
    cout<<boolalpha<<Steps<<endl;
    return;
}

I didn’t understand why should I "cout

I didn’t understand why should I “cout” so many times and which is the mistake

the multiple cout statement not required i have removed them

mistake is that you have interchange the update

 else if(a[i][j]>key){
            j--;        }

here you have use i++ which is wrong