0

I have the following code for Quick Sort procedure:

```
#include<stdio.h>
void Quick_sort(int *arr,int left,int right);
int Partition(int *arr,int left,int right,int pivotindex);
int main()
{
int a[20],n,ctr=0,j=0;
printf("\nEnter number of elements:");
scanf("%d",&n);
printf("Enter array elements:");
while(ctr<n)
{
scanf("%d ",&a[ctr]);
ctr++;
}
Quick_sort(a,0,n-1);
printf("\nSorted Array:");
while(j<n)
{
printf("%d ",a[j]);
j++;
}
return 0;
}
int Partition(int *arr,int left,int right,int pivotindex)
{
int i,temp1,temp2,temp3,storeindex;
storeindex=left;
temp1=arr[pivotindex]; //value at pivot index
//swap pivot with last element//
arr[pivotindex]=arr[right];
arr[right]=temp1;
for(i=left;i<=right-1;i++)
{
if(arr[i]<=temp1)
{
temp2=arr[i];
arr[i]=arr[storeindex];
arr[storeindex]=temp2;
storeindex++;
}
}
//swap pivot with arr[storeindex] for its final place//
temp3=arr[storeindex];
arr[storeindex]=arr[right];
arr[right]=temp3;
return storeindex;
}
void Quick_sort(int *arr,int left,int right)
{
int pivot,newpivot;
if(right>left)
{
pivot=left+(right-left)/2;
newpivot=Partition(arr,left,right,pivot);
Quick_sort(arr,left,newpivot-1);
Quick_sort(arr,newpivot+1,right);
}
}
```

I am not getting any output on running the above code.. Though it compiles fine.. Any suggestion would be a great help! I am using codeblocks as the compiler.