Selection Sort Technique Program in C++

Selection Sort Technique Program in C++

Program to implement the Selection Sort Technique in C++

Selection Sort Technique Program in C++

#include<iostream.h>
#include<conio.h>
void main()
{
int List[100],n,i,j;
cout<<"Enter the size of the list\n";
cin>>n;
cout<<"Enter the elements of the list\n";
for(i=0;i<n;i++)
cin>>List[i];
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(List[i]>List[j])
{
int t = List[i];
List[i]=List[j];
List[j]=t;
}
}
}
cout<<"The Elements in Ascending Order after Selection Sort are:\n";
for(i=0;i<n;i++)
cout<<List[i]<<", ";
getch();
}

Comments