#include<stdio.h>

//quicksort

void quicksort(int a[], int, int);

int partition(int a[],int ,int);

int main()

{

int i,j,a[33],n,p,r,q;

printf(“Enter the total number for sorting\n”);

scanf("%d", &n);

for(i=0;i<n;i++)

{

printf(“Enter the number in array\n”);

scanf("%d", &a[i]);

}

p=i;

r=n-1;

quicksort(a,p,r);

for (i=0;i<n;i++)

{

printf("\n sorted element %d",a[i]);

}

return 0;

```
}
void quicksort(int a[33],int p,int r)
{
int q;
if(p<r)
q=partition(a,p,r);
quicksort(a,p,q-1);
quicksort(a,q+1,r);
}
int partition(int a[33], int p, int r)
{
int x,i, temp;
x=a[r];
i=p-1;
for (int j=p;j<r-1;j++)
{
if(a[j]<=x)
{
i=i+1;
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
temp=a[i+1];
a[i+1]=a[r];
a[r]=temp;
return i+1;
}
```