// Online C compiler to run C program online
#include <stdio.h>
int partition(int a[],int l,int h){
int i,j,p,temp;
i = l+1;
j = h;
p = a[l];
while(i<=j){
while(i<=h && a[i]<p){
i++;
}
while(a[j]>p){
j--;
}
if(i<j){
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
temp = a[l];
a[l] = a[j];
a[j] = temp;
return j;
}
void quickSort(int a[],int l,int h){
if(l<h){
int j = partition(a,l,h);
quickSort(a,l,j);
quickSort(a,j+1,h);
}
}
int main() {
int arr[100];
int arr_size = 5;
printf("Enter the elements:");
for (int i = 0; i < arr_size; i++) {
scanf("%d", &arr[i]);
}
quickSort(arr, 0, arr_size - 1);
printf("Sorted array: ");
for (int i = 0; i < arr_size; i++)
printf("%d ", arr[i]);
return 0;
}