//this code is designed by codenation.
//2:25 15/11/2020
#include<stdio.h>
int main()
{
int i,n,min,loc,temp,j;
printf("enter the size of an data :\n");
scanf("%d",&n);
int a[n];
printf("enter the data :\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n-1;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("the sorted data is:\n");
for(i=0;i<n;i++)
{
printf("%d\n",a[i]);
}
}
//this code is developed by codenation.
Comments
Post a Comment