Thursday, July 30, 2009

linear sort using c language

//program to sort the elements using linear sort
#include
#include
void main()
{
int a[10],n,i,j,temp;
clrscr();

printf("\nEnter the num of elements in the array:");
scanf("%d",&n);
printf("\nEnter the elements into the array");
flushall();
for(i=0;i scanf("%d",&a[i]);

for(i=0;i {
for(j=i+1;j if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
printf("the numbers after sorting are:");
for(i=0;i printf("%d ",a[i]);
getch();

}

No comments:

Post a Comment