/********************************************/
/*PROGRAM TO PERFORM SELECTION SORT*/
/********************************************/
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],n,i,j,temp,min,loc;
clrscr();
printf("Enter the size of array: ");
scanf("%d",&n);
printf("\nEnter the elements of array:\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
min=a[i];
loc=i;
for(j=i+1;j<n;j++)
{
if(min>a[j])
{
min=a[j];
loc=j;
}
}
temp=a[i];
a[i]=a[loc];
a[loc]=temp;
}
printf("\nAfter sorting the elements of array are:\n");
for(i=0;i<n;i++)
{
printf("%d ",a[i]);
}
getch();
}