skip to main
|
skip to sidebar
The 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</N;I++)>
scanf("%d",&a[i]);
for(i=0;i</N;I++)>
{
min=a[i];
for(j=i+1;j<=n-1;j++)
{
if(a[j]</MIN)>
{
min=a[j];
k=j;
}
}
a[k]=a[i];
a[i]=min;
}
printf("THE BUBBLE SORT IS :");
for(i=0;i</N;I++)>
{
printf("%d",a[i]);
printf("\n");
}
getch();
}
You may also like:
{ 0 comments ... read them below or add one }
Post a Comment