## C Program to Sort an Array Using Quick Sort

Quick Sort is one of the most efficient sorting algorithms and is based on the splitting of an array into smaller ones. Worst-case space complexity of Quick Sort is ‎O(n). In this program we will implement Quick Sort Algorithm.

```//C program to quicksort
#include<stdio.h>
void quicksort(int number[50],int f,int l){
int i, j, pt, temp;

if(f<l){
pt=f;
i=f;
j=l;

while(i<j){
while(number[i]<=number[pt]&&i<l)
i++;
while(number[j]>number[pt])
j--;
if(i<j){
temp=number[i];
number[i]=number[j];
number[j]=temp;
}
}

temp=number[pt];
number[pt]=number[j];
number[j]=temp;
quicksort(number,f,j-1);
quicksort(number,j+1,l);

}
}

int main(){
int i, count, number[25];

printf("How many elements are u going to enter?: ");
scanf("%d",&count);

printf("Enter %d elements: ", count);
for(i=0;i<count;i++)
scanf("%d",&number[i]);

quicksort(number,0,count-1);

printf("Order of Sorted elements: ");
for(i=0;i<count;i++)
printf(" %d",number[i]);

return 0;
}
```

##### Output

Please click on the like button if it worked