title: Couldn't get the reason for the fault in the code
body: <p>This is a program to print the smallest value and its position in an array (defined by user).</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int position_smallest(int a[],int n)
  {
      int smallest = a[0];
      int i,k;
      for(i=0; i&lt;=n-1; i=i+1)
      {
          if(a[i]&lt;a[0])
          {
              smallest = a[i];
              k = i;
          }
      }
      printf("The smallest value is %d\n", smallest);
      printf("It's position is %d\n", k); 
      return 0;
   }
  
  int main()
  {
      int n,j;
      int a[n];
      printf("Enter the size of the array: ");
      scanf("%d", &amp;n);
      for(j=0; j&lt;=n; j=j+1)
      {
           printf("a[%d] = ", j);
           scanf("%d", &amp;a[j]);
      }
      position_smallest(a,n); 
  } 
  </code></pre>
  
  <p>But upon running it, it shows following error:</p>
  
  <pre><code>Segmentation fault (core dumped)
  </code></pre>
  
  <p>What can be the possible reason(s) for it?</p>