EmbLogic's Blog

program for bubblesort

#include
#define size 10
int main()
{
int arr[size];
int i,j,temp;
printf(“Enter the array \n”);
for(i=0;i<size;i++)
scanf("%d",&arr[i]);

printf("The array is :\n");
for(i=0; i < size; i++)
printf("arr[%d]:%d\n",i,arr[i]);

printf("String after bubble sort ");
for(j=0 ; j<size ; j++)
{
for(i=0 ; i arr[i+1])
{
temp=arr[i+1];
arr[i+1]=arr[i];
arr[i]=temp;
}
}
for(i=0 ; i<size ; i++)
printf("arr[%d] :%d\n ",i,arr[i]);

return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>