title: What is the mistake in the following code?
body: <p>while running, max is giving desired maximum number from the list of numbers but the min is not giving minimum number which it is supposed to give.?
  For example:</p>
  <p>If the input is :</p>
  <blockquote>
  <p>5 <br>
  45 7 2 1 4</p>
  </blockquote>
  <p>The output from the below code is:</p>
  <blockquote>
  <p>Maximum number is 45</p>
  <p>Minimum number is 0</p>
  </blockquote>
  <p>Why ?</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;limits.h&gt;
  #define MX 1000000
  
  int max=INT_MIN;
  int min=INT_MAX;
  
  int findmax(int a[],int n)
  {
      if(n&lt;0)
          return max;
      if(a[n]&gt;max)
      {
          max=a[n];
      }
      return findmax(a,n-1);
  }
  
  int findmin(int a[],int n)
  {
      if(n&lt;0)
          return min;
      if(a[n]&lt;min)
      {
          min=a[n];
      }
      return findmin(a,n-1);
  }
  
  int main(void) {
      int a[MX],n,i;
      printf(&quot;Enter the number of elements:\n&quot;);
      scanf(&quot;%d&quot;,&amp;n);
      for(i=0;i&lt;n;i++)
      {
          scanf(&quot;%d&quot;,&amp;a[i]);
      }
      printf(&quot;Maximum number is %d\n&quot;,findmax(a,n));
      printf(&quot;Minimum number is %d\n&quot;,findmin(a,n));
      return 0;
  }
  </code></pre>