0% found this document useful (0 votes)
6 views1 page

Quick - Sort Program in C Language For Practise

The document contains a C program that demonstrates the Quick Sort algorithm. It allows the user to input up to 10 integers, sorts them using the Quick Sort method, and then displays the sorted order. An example output is provided, showing the sorted result for a specific input of eight numbers.

Uploaded by

Shivam chavan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Quick - Sort Program in C Language For Practise

The document contains a C program that demonstrates the Quick Sort algorithm. It allows the user to input up to 10 integers, sorts them using the Quick Sort method, and then displays the sorted order. An example output is provided, showing the sorted result for a specific input of eight numbers.

Uploaded by

Shivam chavan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

22/05/2023, 22:04 127.0.0.1:5500/02.Quick_Sort.

// 02.Programm to demonstrate the concept of QUICK sort

#include <stdio.h>
void quicksort(int number[10], 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, count, number[10];
printf("How many elements you want to enter (Max Size 10): ");
scanf("%d", &count);

printf("Enter %d elements : ", count);


for (i = 0; i < count; i++)
scanf("%d", &number[i]);
quicksort(number, 0, count - 1);
printf("The Sorted Order is:");
for (i = 0; i < count; i++)
printf(" %d", number[i]);
return 0;
}

/*
OUTPUT:
How many elements you want to enter (Max Size 10): 8
Enter 8 elements : 56 54 23 15 65 87 96 32
The Sorted Order is: 15 23 32 54 56 65 87 96
*/

127.0.0.1:5500/02.Quick_Sort.c 1/1

You might also like