quicksort program in c

quicksort in c:

Quicksort is a sorting method it arranges the element either ascending order or descending order. Quicksort is similar to mergesort it is also divided and conquers algorithm. In this blog, I will explain the quicksort problem, quicksort program with the output.

quicksort code in c:

```#include<stdio.h>
void quicksort(int number[25],int first,int last){
int i, j, pivot, temp;

if(first<last){
pivot=first;
i=first;
j=last;

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

temp=number[pivot];
number[pivot]=number[j];
number[j]=temp;
quicksort(number,first,j-1);
quicksort(number,j+1,last);

}
}

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

printf("Enetr the number of element ");
scanf("%d",&n);

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

quicksort(number,0,n-1);

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

return 0;
}
```

Output: