Advertise With us

 

Selection sorting Technique

#include<stdio.h>//header file
#include<conio.h>//header file
void main()
{
int i,l,a[10],j,t;
clrscr();
printf("enter the length of the list");
scanf("%d",&l);
printf("enter the elements in the list");
for(i=0;i<l;i++)//for loop
scanf("%d",&a[i]);
for(i=0;i<l-1;i++)
{
for(j=i+1;j<l;j++)
{
if(a[i]>a[j])//if(condition)
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
printf("the elements after selection sorting is=");
for(i=0;i<l;i++)
printf("%d ",a[i]);
getch();
}

Google