title: QuickSort in C not working as expected
body: <p>I tried to implement QuickSort in C, but not getting the correct result. This is the program i wrote. </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int partition(int a[],int low,int high)
  {
      int pivot = a[high];
      int temp;
      int i = low-1;
      int j=0;
      for(j=0;j&lt;high-1;j++)
      {
          if(a[j]&lt;=pivot)
          {
              i=i+1;
              temp = a[i];
              a[i] = a[j];
              a[j] = temp;    
          }       
      }
      temp = a[i+1];
      a[i+1] = pivot;
      a[high] = temp;
      return (i+1);   
  }
  
  void quick_sort(int a[],int low,int high)
  {
      if(low&lt;high)
      {
          int q = partition(a,low,high);
          quick_sort(a,low,q-1);
          quick_sort(a,q+1,high);
      }
  }
  
  main()
  {
      int i,n,a[10];
      printf("\nEnter the number of elements in the array : ");
      scanf("%d",&amp;n);
      printf("\nEnter the elements in the array : "); 
      for(i=0;i&lt;n;i++)
      {
          scanf("%d",&amp;a[i]);
      }
      printf("\nElements in the array before sorting : ");    
      for(i=0;i&lt;n;i++)
      {
          printf (" %d",a[i]);
      }
      quick_sort(a,0,n-1);
      printf("\nElements in the array after sorting : "); 
      for(i=0;i&lt;n;i++)
      {
          printf (" %d",a[i]);
      }
      printf("\n");
  }
  </code></pre>
  
  <p>I gave input as 0,4,2,7 but the result is 4,0,7,2. I couldn't able to find the issue with this code. Can someone help me ?</p>