getting a error message
saying
"thread stopped"
program is based on sorting
plz help
It's hard to guess what's wrong without seeing the code but from the error message it sounds as if the thread has stopped ;)
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void selsort();
void bubsort();
void menu();
void main()
{menu();}
void menu()
{
top:
clrscr();
int ans;
cout<<"\t\tsorting menu";
cout<<"\n1.sort element using sel sort";
cout<<"\n2.sort element using bubble sort";
cout<<"\n3.exit";
cin>>ans;
switch(ans)
{
case 1 :selsort();
break;
case 2 :bubsort();
break;
case 3 :exit(0);
break;
}
}
void selsort()
{
int ar[50], size, temp, pos, small;
cout<<"enter size of array";
cin>>size;
cout<<"enter array";
for(int i=0;i<size;i++)
{cin>>ar[i];
}
for(int i=0;i<size;i++)
{ small=ar[i];
for(int j=i+1;j<size;j++)
{
if(ar[j]<small)
{
small=ar[j];
pos=j;
}
}
temp=ar[i];
ar[i]=ar[pos];
ar[pos]=temp;
cout<<"\n";
for(int k=0;k<size;k++)
cout<<"\t"<<ar[k];
}
cout<<"array";
for(int i=0;i<size;i++)
{cout<<ar[i];
}
getch();
menu();
}
void bubsort()
{int ar[50],size,temp;
cout<<"enter size of array";
cin>>size;
cout<<"enter array";
for(int i=0;i<size;i++)
{cin>>ar[i];
}
for(int i=0;i<size;i++)
{
for(int j=0;j<size-1-i ;j++)
{
if(ar[j]<ar[j+1])
{
temp=ar[j];
ar[j]=ar[j+1];
ar[j+1]=temp;
}}
}
for(int i=0;i<size;i++)
{cout<<"\t"<<ar[i];
}
}
and the cursor position itself at
this line 'ar[j]=ar[j+1];'