title: Searching an element in an Array using Recursive Function in C Language
body: <p>I am a beginner to arrays in recursion so need some guidance.
  I am trying to find whether an element is present in an array or not.</p>
  
  <pre class="lang-c prettyprint-override"><code>// Program to find whether an element exist in an array or not.
  #include &lt;stdio.h&gt;
  int arr[5]= {1,2,3,4,5};
  
  int fooSearch(int array1[],int N,int i, int X)
  {
      if(i==N)
        return 0;
      else if (array1[i]==X)
        return 1;
      else 
        return fooSearch(array1,N,i++,X); 
  }
  
  // N denotes total size 5
  // i counter that moves from 0 to 4 and eliminate recursion when it reaches 5
  // X is the element to be found
  
  
  int main() {
      fooSearch(arr,5,0,3);
      return 0;
  }
  
  </code></pre>
  
  <p>The error I obtained is <code>Segmentation Fault (SIGSEGV)</code>.</p>
  
  <p>Please guide me what wrong I am doing with this code.</p>