Selection sort - C program:
Write a program to define a selection sort.
void main()
{
clrscr();
int a[100],ch,n;
cout<<"enter the limit for the array : ";
cin>>n;
for (int i=0;i
{
cout<<"enter element "<
cin>>a[i];
}
clrscr();
cout<<"1. selection sorting"<
ssort(a,n);
}
}
void ssort(int a[100],int n)
{
clrscr();
int i,min,po,j,t;
for(i=0; i
{
min=a[i];
po=i;
for (j=i+1; j
{
if (a[j]
{
min=a[j];
po=j;
}
}
t=a[po];
a[po]=a[i];
a[i]=t;
}
cout<<" sorted arrays by selection "<<"\n\n";
for(i=0;i
cout<
getch();
}