#include <stdio.h>
main()
{
int a[100],i,j,n,t,min,minpos;
printf("enter size of the array");
scanf("%d",&n);
printf("enter %d elements of the array",n);
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
for(j=1;j<=n-1;j++)
{
min=a[j];
minpos=j;
for(i=j+1;i<=n;i++)
{
if(min>a[i])
	{ min=a[i];
	  minpos=i;
	
t=a[j];
a[j]=a[minpos];
a[minpos]=t;
}
}
}
printf("\n sorted array is : ");
for(i=1;i<=n;i++)
{
printf("%d \n",a[i]);
}
}
     
           
Note: Need to be arranged in compiler after copied
   

 OutPut:

Enter the size of the array: 5 Enter elements into the array 8 3 7 1 5 The Sorted array is: 1 3 5 7 8