#include <stdio.h>
#include <conio.h>
void main()
{
int a[10], i, j, temp,minindex;
printf("enter 10 unsorted array elements");
for(i=0; i<10; i++)
{
scanf("%d", &a[i]);
}
//selection sort logic to sort the elements in ascending order.
for(i=0; i<9; i++)
{
minindex=i;
for(j=i+1; j<10; j++)
{
if(a[j]<a[minindex]) // swap the position if next element is smaller
{
minindex=j;
}
}
temp=a[i];
a[i]=a[minindex];
a[minindex]=temp;
}
printf("sorted elements are as follows\n");
for(i=0; i<10; i++)
{
printf("%d ", a[i]);
}
}