EmbLogic's Blog

C program for bubble sorting

#include
int main()
{
int i,j,k,a[100],n;
printf(“Enter size of array:”);
scanf(“%d”,&n);
printf(“Enter element of an array:”);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;ja[j+1])
{
k=a[j];
a[j]=a[j+1];
a[j+1]=k;
}
}
}
printf(“Array after bubble sorting:\n”);
for(i=0;i<n;i++)
{
printf("a[%d]=%d\n",i,a[i]);
}
}

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>