C program for quick sort in ascending order

A simple C program for quick sort in ascending order. This sorting program is the best and fastest sort program among other sorting programs for the beginners in every programming language. Quicksort program in C programming language. Quick sort program is based on the ascending order method and this how it works. This is the fastest sorting algorithm in c programming language. This is program executed the result as soon as possible this is reason behind the name quick sort.

#include<stdio.h>
void sort(int num[25],int first,int last)
{
int i, j, pivot, temp;
if(first<last){
pivot=first;
i=first;
j=last;
while(i<j)
{
while(num[i]<=num[pivot]&&i<last)
i++;
while(num[j]>num[pivot])
j--;
if(i<j)
{
temp=num[i];
num[i]=num[j];
num[j]=temp;
}
}
temp=num[pivot];
num[pivot]=num[j];
num[j]=temp;
sort(num,first,j-1);
sort(num,j+1,last);
}
}
int main()
{
int i, count, num[25];
printf("How many elements do you want?");
scanf("%d",&count);
printf("Enter %d elements: ", count);
for(i=0;i<count;i++)
scanf("%d",&num[i]);
sort(num,0,count-1);
printf("After sorting");
for(i=0;i<count;i++)
printf(" %d",num[i]);
return 0;
}

 

Output:

How many elements do you want? 3

Enter 3 elements:

34 56 78

After sorting 34 56 78