Bubble Sort Program: 


C Program


In this article we have to create a c program for a bubble sort. here we can write a 'c' program for a bubble sort using platform 'turbo c'. 










C Program Code : 


#include<stdio.h>
#include<conio.h>
void bubblesort(int a[20],int n)
{
int i,j,temp;
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}
main()
{
int a[100],i,n;
clrscr();
printf("Enter How Many Elements Would You Like To Enter :");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter Data:");
scanf("%d",&a[i]);
}
bubblesort(a,n);
printf("The Array After Sorting Is :\n");
for(i=0;i<n;i++)
{
printf("%d\t",a[i]);
getch();
}


                   Thanks For Spending Your Time On My Site.....