i have written the following code but it is not working well in the case of merge sort.can anyone able to help me?


#include<iostream.h>



void selectsort(int *);
void mergesort(void);
void merge(int*,int,int,int);
linearsearch();
binarysearch();
void main()
{
int choice;
int searchnum;
int num[10];
int i;
int k;
cout<<"=========================================== =====================================\n";
cout<<" Welcome To The Sorting Program!\n\n";
cout<<"=========================================== =====================================\n";

cout<<" Please select any sorting algorithm from the following: \n\n";
cout<<" [1] Selection Sort.\n";
cout<<" [2] Quick Sort.\n";
cout<<" [3] Merge Sort.\n";
cout<<" [4] Quit.\n\n";
cin>>choice;
if(choice!=4)
{
cout<<"Please enter 10 numbers to sort.\n\n";
for( i=0, k=0;i<10;i++,k++)
{
cout<<"Enter the "<<i+1<<" number ";
cin>>num[k];
}
if(choice==1)
selectsort(num);
if(choice==2)
// quicksort();
if(choice==3)
void mergesort(int num,int first,int last);

cout<<"Please select any searching algorithm from the following:\n";
cout<<" [1] Linear Search.\n";
cout<<" [2] Binary Search.\n";
cin>>searchnum;
if(searchnum==1)
{
int no;
int i;
int check=0;
cout.flush();
cout<<"Please enter the number you want to search:";
cin>>no;
cout<<endl;
for(i=0;i<10;i++)
if(num[i]==no )
{
check++;
if(check==1)
{
cout<<"The number is present in the sorted list.\n\n\n";
cout<<"=========================================== =====================================\n";
}
}
if(check==0)
{
cout<<"Sorry,the number is not found.\n\n";
cout<<"=========================================== =====================================\n";
}
}
if(searchnum==2)
{
int middle;
int low=0;
int high=10;
int key;
int check=0;
cout<<"Please enter the number you want to search:";
cin>>key;
cout<<endl;
while(low<=high && check==0)
{
middle=(low+high)/2;
if(key==num[middle])
{
check++;
if(check==1)
{
cout<<"The number is present in the sorted list.\n\n\n";
cout<<"=========================================== =====================================\n";
}
}
if(key<num[middle])
high=middle-1;
else
low=middle+1;
}
if(check==0)
{
cout<<"Sorry,the number is not found.\n\n";
cout<<"=========================================== =====================================\n";
}
}

}
cout<<"=========================================== =====================================\n";
cout<<" Thank you for using the program!\n\n";
cout<<"=========================================== =====================================\n";
}

void selectsort(int num[10])
{
int i;
int j;
int k;
int min;
int temp;
int searchnum;
for (i=0; i<9 ; i++)
{
min = i;
for (j = i+1; j<10; j++)
if (num[j] < num[min])
min = j;
temp = num [min];
num [min] = num [i];
num [i] = temp ;
}

cout<<"The sorted numbers are\n";
for(i=0,k=0;i<10;i++,k++)
cout<<num[k]<<endl;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
//********************MERGESORT********************* *******
/*void mergesort(int* d, int first, int last)
{
// Mergesort Function to sort an array of integers.
int mid = 0;
if (first < last)
{
mid = (first+last) / 2;
mergesort(d, first, mid);
mergesort(d, mid+1, last);
merge(d, first, mid, last);
}
}


void merge(int* d, int first, int mid, int last)
{
// Merge function to combine two lists into one.
int* temp = new int[last+1];
int nextleft = first;
int nextright = mid+1;
int i = first;
while ((nextleft<=mid) && (nextright <= last))
{
if (d[nextleft] < d[nextright])
{
temp[i] = d[nextleft];
i++;
nextleft++;
}
else
{
temp[i] = d[nextright];
i++;
nextright++;
}
}
while (nextleft <= mid)
{
temp[i] = d[nextleft];
i++;
nextleft++;
}
while (nextright <= last)
{
temp[i] = d[nextright];
i++;
nextright++;
}
for (i=first; i <= last; i++)
{
d[i] = temp[i];
}

}
*/