# Quick Sort in C

```A quick sort program that I wrote using C programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My mobile number here in the Philippines is 09173084360.

=================================================

You can buy my C++ book online at

Beginner’s Guide To C++ Programming

You can buy my book in introduction to computer networking at

https://www.unlimitedbooksph.com/product-page/introduction-to-computer-networking

Want to support my channel?

GCash Account

09173084360

Paypal

Patreon

Thank you very much for your support.

```

``````#include <stdio.h>
#include <stdlib.h>

int  Quick_Sort(int *items, int left, int right) {
int pivot = left;
int i = left +1, j = right, temp;
if (left < right) {
while (1) {
while (items[j] > items[pivot])
j--;
while (items[i] <= items[pivot])
i++;
if (i < j) {
temp = items[i];
items[i] = items[j];
items[j] = temp;
} else
break;
}
temp = items[pivot];
items[pivot] = items[j];
items[j] = temp;
Quick_Sort(items, left, j-1);
Quick_Sort(items, j+1, right);
}
return 0;
}

int main() {
int a=0,num=0, *items;

printf("\n");
printf("\tQuick Sort in C");
printf("\n\n");
printf("\tHow Many Items?  : ");
scanf("%d", &num);
items = (int *)malloc(sizeof (int) * num);
printf("\n\n");
for (a = 0; a < num; a++) {
printf("\tEnter Value in Item No. %d : ",a+1);
scanf("%d", &items[a]);
}
printf("\n\n");
printf("\tBefore Sorting\n");
printf("\n\n");
printf("\t");
for (a = 0; a < num; a++)
printf("%5d",items[a]);
printf("\n");
Quick_Sort(items, 0, num-1);
printf("\n\n");
printf("\tAfter Sorting:\n");
printf("\n\n");
printf("\t");
for (a= 0; a < num; a++)
printf("%5d", items[a]);
printf("\n\n");
printf("\tEnd of Program");
printf("\n");
}``````