1. ## please see my program

Code:
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
int c;
void insertionsort(int x[],int length)
{
int key,i;
for(int j=1;j<length;j++)
{
key=x[j];
i=j-1;
while(x[i]>key && i>=0)
{
x[i+1]=x[i];
i--;
}
x[i+1]=key;
}
printf("After  insertionsort: ");
for(i = 0; i < 10; i++) {
printf(" %d ", x[i]);
}
printf("\n");
}

void recursive_quicksort(int arr[], int low, int high ) {
int i = low;
int j = high;

/* compare value */
int z = arr[(low + high) / 2];

/* partition */
do {
/* find member above ... */
while(arr[i] < z) i++;

/* find element below ... */
while(arr[j] > z) j--;
int y;
if(i <= j) {
/* swap two elements */
y = arr[i];
arr[i] = arr[j];
arr[j] = y;
i++;
j--;
}
} while(i <= j);

/* recurse */
if(low < j)
recursive_quicksort(arr, low, j);

if(i < high)
recursive_quicksort(arr, i, high);
}

void Swap(int x, int y){
int temp = x;
x = y;
y = temp;
}//end swap
void choosePivot(int theArray[], int first, int last){
int pivot;

//find middle of array
int middle = last - first;
//compare first middle and last item in array
if((first < last)&&(last > middle)){
if(first < middle){
//middle is median number
pivot = middle;
}else{
//first is median number
pivot = first;
}
}else if((first < middle)&&(middle > last)){
if(first < last){
//last is median number
pivot = last;
}else{
//first is median number
pivot = first;
}
}else{
if(last < middle){
//middle is median number
pivot = middle;
}else{
//last is median
pivot = last;
}
}
}
void partition(int theArray[], int first, int last, int pivotIndex){

choosePivot(theArray, first, last);

int pivot = theArray[first];

int lastS1 = first;

int firstUnknown = first + 1;

for(; firstUnknown <= last; ++firstUnknown){

if(theArray[firstUnknown] < pivot){

++lastS1;
Swap(theArray[firstUnknown], theArray[lastS1]);
}//end if

Swap(theArray[first], theArray[lastS1]);
pivotIndex = lastS1;
}// end partition

}

void quicksort(int theArray[], int first, int last){
int pivotIndex;

if(first < last){
//create the partition: S1, pivot, S2
partition(theArray, first, last, pivotIndex);

}
}

int main(void) {
int array[10] ;
int i = 0;
for(i = 0; i < 10; i++)
array[i] = rand() % 100;
int ch;
printf("\n1. insertion sort\n");
printf("\n2. recursive quick sort\n");
printf("\n3. non_recursive quick sort\n");
printf("\n4. Exit Program");
printf("\n----------------------------------");
printf("\nSelect any one of the above==>");
scanf("%d",&ch);
/* print the original array */
switch(ch){
case 1:
printf("Before sorting the array: ");
for(i = 0; i < 10; i++) {
printf(" %d ", array[i]);
}
printf("\n");
insertionsort(array, 10);
break;
case 2:
printf("Before sorting the array: ");
for(i = 0; i < 10; i++) {
printf(" %d ", array[i]);
}
printf("\n");
recursive_quicksort(array, 0, (10 - 1));
printf("After  non_recursive quicksort: ");
for( i = 0; i < 10; i++) {
printf(" %d ", array[i]);
}
printf("\n");
break;
case 3:
printf("Before sorting the array: ");
for(i = 0; i < 10; i++) {
printf(" %d ", array[i]);
}
printf("\n");
quicksort(array,0,9);
break;
case 4:
printf("you are out of the menue");
}

c=getchar();
return 0;

}

2. It's not surprising you can't find any problems in your code - you have absolutely no structure! The compiler doesn't care how your code is formatted, but other programmers do. You'll find you'll get a lot more help from others when you provide neatly formatted code (and, oddly enough, you might find you need less help from others if you format your code!)

Assuming this is supposed to be a C program, the first thing you need to do is remove the <iostream> library - that's a C++ library.

Now, can you be a bit more explicit about what problem you're having? If I had to guess, I'd say it was with your choosePivot function. It appears to do nothing. Look there first.

Kevin

3. To follow up what kmess said.
Read this -> SourceForge.net: Indentation - cpwiki

4. I thought there was no programme without a "main()" function....???
this programme doesn't have one so isn't it a basic mistake...??

5. Originally Posted by Lord Slytherin
I thought there was no programme without a "main()" function....???
this programme doesn't have one so isn't it a basic mistake...??
It's there... look again.

The OP needs to do several very important things...

1) learn how to indent code so that it is readable... Indentation sould reflect levels of loops and if statements... Salem has provided a very good link for this.

2) Read the actual error messages from his compiler and linker and eliminate them one by one.

3) if the program compiles he needs to test run it, knowing behaviorally where it acts up provides powerful hints where the problems are.

In any event... coming in here and asking us to fix his broken code without even ha hint of what's wrong is very unlikely to work, even at the most generous of times.

thanks a gain

7. Any luck, Susu?

Kevin

8. Originally Posted by kmess
Any luck, Susu?

Kevin
LOL... Ok, I get why some of the people asking questions are impatient... but when answering ????

9. Originally Posted by CommonTater
LOL... Ok, I get why some of the people asking questions are impatient... but when answering ????

10. I guess we have different motivations in helping people. For instance, I like to see that people are making progress toward solving their problems. What's your motivation?

Kevin

11. Originally Posted by kmess
I guess we have different motivations in helping people. For instance, I like to see that people are making progress toward solving their problems. What's your motivation?

Kevin
Old saying.... "You can't help anyone who's not asking for help"...

The best motivation here --given that a huge majority of posts are from people taking classes-- is to educate.
The best way to educate is to motivate people toward self-actualization... point them in the right direction and hope they can read a compass.