### Implement the quick sort algorithum using recuesive function

Hello, guys I have written this code to arrange user input array in an order. However, I am not able to figure the error on this code that i have witten pls help me out
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647`` ``````//Recursive Quick Sort #include #define ARRAY_SIZE 10 void quick_sort(int array[], int len) { int a[ARRAY_SIZE], c, d, pos; for(c = 0; c a[d]) // error is in this line pos = d; } if (pos !=c) { int swap; swap = a[c]; a[c] = a[pos]; a[pos] = swap; } } printf("Sorted list\n"); for( c=0; c
What makes you thik that there is an error there?
First I noticed that you passing array bur sorting uninitializated local array a
You are using elements in the a array without initializing them.
it's neither quick sort (instead it's bubblesort) nor recursive.

use `array` in place of `a` in your `quick_sort()` function
@ Miinippa I debugged my code form visual studio and every time i run it value at this line are always negative number....
@coder777 how can i make it recursive. I cant use for loop...
`I debugged my code form visual studio and every time i run it value at this line are always negative number.... `
Of course it will be random number! You are sorting uninitializated local array a

As coder777 says use array instead of a
Topic archived. No new replies allowed.