title: How do I write a function to search for an element in two dimensional array?
body: <p>How do I write a function to search for an element in two dimensional array: if exists returns 1, otherwise returns no?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  
  int search(int a[3][3],int x);
  
  int main ()
  {
      int Array[3][3]; // array of size 3*3
      int i,j;         //counters i,j
      int result,number;    
  
  
      for(i=0;i&lt;3;i++)
      {
          printf("\n");
          for(j=0;j&lt;3;j++)
          {     
              printf(" Array[%d][%d]= ",i,j);
              scanf("%d", &amp;Array[i][j]);              //Fill The 3*3 array
          }
      }
  
      printf("Enter The number you want:&gt;");
      scanf("%d",&amp;number);
  
      result=search(Array,number);
  
      if(search(Array,number))
          printf("Number exists\n");
      else
         printf("Number does not exists\n");
  
      return 0;
  }
  
  
  int search(int a[3][3],int x){
      int i,j;
      for(i=0;i&lt;3;i++){
  
          for(j=0;j&lt;3;j++){
  
             if (x==a[i][j])
                 return 1;
             return 0;
          }
      }
  }
  </code></pre>
  
  <p>is this right ??</p>