Program
#include <stdio.h>#include <conio.h>
void main()
{
int a[8],i,ptr,c;
clrscr();
printf("Enter Eight inputs :- \n ");
for(i=0;i<8;++i)
scanf("%d",&a[i]);
printf("\n Bubble \n");
for(i=1;i<=7;++i)
{
ptr=0;
while(ptr<=(8-i))
{
if(a[ptr]>a[ptr+1])
{
c=a[ptr];
a[ptr]=a[ptr+1];
a[ptr+1]=c;
}
ptr++;
}
}
printf("After bubble sort\n");
for(i=0;i<8;++i)
printf("%d ",a[i]);
getch();
}
No comments:
Post a Comment