Couldn't get the reason for the fault in th code : This is a program to print the smallest value and its position in an array (defined by user).

    #include <stdio.h>
    int position_smallest(int a[],int n)
    {
     int smallest = a[0];
     int i,k;
     for(i=0; i<=n-1; i=i+1)
     {
      if(a[i]<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", &n);
     for(j=0; j<=n; j=j+1)
     {
      printf("a[%d] = ", j);
      scanf("%d", &a[j]);
      }
     position_smallest(a,n); 
     } 
But upon running it, it shows following error:
   

    Segmentation fault (core dumped)
What can be the possible reason(s) for it?