-- --

Bubble Sort using C

This program shows the implementation of Bubble Sort using C:


#include<stdio.h>
#include<conio.h>
void main()
{
 int a[5],i,j,t,n.k;
 printf("Enter the no. of elements:");
 scanf("%d",&n);
 printf("Enter the element of the array:",n);
 for(i=0;i<n;i++)
 {
  scanf("%d",&a[i]);
 }
 for(j=0;j<n;j++)
 {
  for(k=0;k<n-j-1;k++)
  {
   if(a[k]>a[k+1])
   {
    t=a[k];
    a[k]=a[k+1];
    a[k+1]=t;
   }
  }
 }
 printf("Sorted list is:");
 for(i=0;i<n;i++)
 printf("%d",a[i]);
 getch();
}

kaliadevansh has written 15 articles

2 thoughts on “Bubble Sort using C

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=""> <s> <strike> <strong>