wap to implement selection sort
#include<stdio.h>
#include<conio.h>
void main()
{
int s,i,j,temp,a[20];
clrscr();
printf("\n enter total
element:");
scanf("%d",&s);
printf("\n enter %d element
:",s);
for(i=0;i<s;i++)
scanf("%d",&a[i]);
for(i=0;i<s;i++)
{
scanf("%d",&a[i]);
for(i=0;i<s;i++)
for(j=i+1;j<s;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("after sorting is
:");
for(i=0;i<s;i++)
printf("%d",a[i]);
getch();
}
No comments:
Post a Comment