#include<stdio.
h>
void swap(int *a,int *b){
int temp=*a;
*a=*b;
*b =temp;
}
int partition(int a[],int low,int high){
int pivot=a[high];
int i=low-1;
int j;
for(j=low;j<high;j++){
if(a[j]<pivot){
i++;
swap(&a[i],&a[j]);
}
}
swap(&a[i+1],&a[high]);
return i+1;
}
void quicksort(int a[],int low,int high){
if(low<high){
int pi=partition(a,low,high);
quicksort(a,low,pi-1);
quicksort(a,pi+1,high);
}
}
void display(int a[],int size){
for(int i=0;i<size;i++){
printf("%d\t",a[i]);
}
}
void main(){
int i,size,a[20];
printf("Enter the Size of the array");
scanf("%d",&size);
printf("Enter the elements of the array");
for(i=0;i<size;i++){
scanf("%d",&a[i]);
}
printf("Before sorting\n");
display(a,size);
quicksort(a,0,size-1);
printf("\nAfter sorting\n");
display(a,size);
}