Selection sort is a sorting algorithm, specifically an in-place comparison sort. Selection sort is noted for its simplicity, and also has performance advantages over more complicated algorithms in certain situations.
Language : C
[sourcecode language='c']
//Selection Sort
#include
void main()
{
int a[100],small,p,temp,j,i,n;
printf(“Enter the value for n :”);
scanf(“%d”, &n);
for(i=0;i
scanf(“%d”, &a[i]);
}
for(i=0;i
p=i;
for(j=i+1;j
if(a[j]
{
small=a[j];
p=j;
}
}
temp=a[i];
a[i]=a[p];
a[p]=temp;
}
printf(“The sorted array is : “);
for(i=0;i
}
[/sourcecode]






