Bubble sort Program



#include
main()
{
int a[10],n,i,pass;
system("clear");
printf("\nEnter the number of elements : ");
scanf("%d",&n);
printf("\nEnter the elements one by one...\n");
for(i=0;iscanf("%d",&a[i]);
printf("\nMaking the sorting of elements in Bubble Sort...\n");
for(pass=0;passfor(i=0;iif (a[i]>a[i+1])
{
a[i]=a[i]+a[i+1];
a[i+1]=a[i]-a[i+1];
a[i]=a[i]-a[i+1];
}
printf("\nElements in the order after Bubble sort..\n");
for(i=0;iprintf("%d\n",a[i]);
}


No comments: