C++ Program for Selection sort


#include<conio.h>   	
#include<iostream.h>
#include<process.h>
 
void main()
{
int array[100],n,i,j,temp;
clrscr();
cout<<"How many numbers--> ";
cin>>n;
cout<<"Enter "<<n<<" numbers\n";
for(i=0;i<n;i++)
cin>>array[i];
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
if(array[i]>array[j])
{
temp=array[i];
array[i]=array[j];
array[j]=temp;
}
}
cout<<"\nArray is sorted in ascending order.\n";
for(i=0;i<n;i++)
cout<<array[i]<<" ";
getch();
}