title: if an element in an MxN matrix is 0, its entire row and column is set to 0
body: <pre><code>void zero(int a[][4],int m,int n){
  bool row[m], col[n];
  memset(row,false,sizeof(row));
  memset(col,false,sizeof(col));
  for(int i = 0;i&lt;m;i++)
  {
      for(int j= 0;j&lt;n ; j++ )
      {
      if(a[i][j]==0){
          row[i]=true;
          col[j]=true;
      }    
      }
  }
  for(int i=0;i&lt;m;i++){
      for(int j=0;j&lt;n;j++){
          if(row[i] || row[j])
          a[i][j]=0;
      }
  } 
  
  }
  int main(){
  int a[][4]={
  {1,2,3,4},
  {1,2,4,5},
  {4,0,6,7},
  {3,6,3,56},
  }
  zero(a,4,4);
  for(int i = 0 ; i&lt;4;i++){
  for(int j = 0;j &lt; 4 ; j++){
      cout &lt;&lt; a[i][j]&lt;&lt;" " ;
  }cout &lt;&lt;endl;
  }
  }
  </code></pre>
  
  <p>Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0.
     so here is my code. as you can see the a[2][1] = 0 , so row 2 and col 1 supposed to be 0. but my result is row 2 and col 2 are 0 . really confused ...please help </p>