BUBBLE SORT
he bubble sort program is a data structure sorting techniques.It is used to sort the elements ascending or descending order.
EXAMPLE:
void main()
{
int a[100],i,j,t,n,min,k;
clrscr();
printf("\n-------------------------\n");
printf("ENTER THE TOTAL NUMBER:");
scanf("%d",&n);
printf("ENTER THE VALUE ONE BY ONE:");
for(i=0;i
scanf("%d",&a[i]);
for(i=0;i
{
min=a[i];
for(j=i+1;j<=n-1;j++)
{
if(a[j]
{
min=a[j];
k=j;
}
}
a[k]=a[i];
a[i]=min;
}
printf("THE BUBBLE SORT IS :");
for(i=0;i
{
printf("%d",a[i]);
printf("\n");
}
getch();
}
0 comments:
Post a Comment