Where is this code is wrong

#include
using namespace std;
int main() {
int m,n,i,j,key;
cin>>m;
cin>>n;

int a[m][n];
for(i=0; i<m; i++){
	for(j=0; j<n; j++){
		cin>>a[i][j];
	}
}
cin>>key;
for(i=0; i<m; i++){
	for(j=0; j<n; j++){
		if(a[i][j]=key){
			cout<<"1"<<endl;
		}
		else{
			cout<<"0"<<endl;
		}
	}
}
return 0;

}

hi @rathidevesh906_1dcc73a061c159bb,
you r printing 0 or 1 at each cell instead traverse all at once and if u found key anywhere make one ans variable and make it true which initially is false
when u come out of loop if the ans is true print 1 else print 0

also its n*m not m*n

and a[i][j] == key not a[i][j] = key

check here ive updated and commented https://ide.codingblocks.com/s/661263

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.