Wednesday, September 17, 2008

BUBBLE SORT in in c programming language

42. BUBBLE SORT

void main()
{
int s,temp,i,j,a[20];
clrscr();
printf("\nEnter size of the array: ");
scanf("%d",&s);
printf("\nEnter %d elements in to the array:",s);
for(i=0;i
scanf("%d",&a[i]);
for(i=0;i
{
for(j=0;j
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("\nThe array after sorting is: ");
for(i=0;i
printf(" %d",a[i]);
getch();
}

No comments:

Post a Comment

Thanks to given comments.......

My Blog List