#include<stdio.h>
int main()
{
    int a[200],n,i,j,temp;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    printf("Unsorted List\n");
    for(i=0;i<n;i++)
    {
        printf("%d\t",a[i]);
    }
    for(i=0;i<=n-2;i++)
    {
        int pos=i;
        for(j=i+1;j<=n-1;j++)
        {
            if(a[pos]>a[j])
            {
                pos=j;
            }
        }
        temp = a[i];
        a[i] = a[pos];
        a[pos]=temp;
    }
    printf("\nSELECTION SORT\nSorted List\n");
    for(i=0;i<n;i++)
    {
        printf("%d\t",a[i]);
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: