#include<stdio.h>
void display(int a[],int n);
void bubblesort(int a[],int n);
int main()
{
int a[200],i,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\nUnsorted List\n");
display(a,n);
bubblesort(a,n);
printf("\nBUBBLE SORT\nSorted List\n");
display(a,n);
return 0;
}
void display(int a[],int n)
{
int i;
for(i=0;i<n;i++)
{
printf("%d\t",a[i]);
}
}
void bubblesort(int a[],int n)
{
int i,j;
for(int j=1;j<=n-1;j++)
{
for(i=0;i<=n-j-1;i++)
{
if(a[i]>a[i+1])
{
int temp = a[i];
a[i]=a[i+1];
a[i+1]=temp;
}
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: