C++ Programming Code for Bubble Sort
#include<iostream>
using namespace std;
int main()
{
int a[50], n,i,j,tmp;
cout<<"enter size of array";
cin >>n;
cout<<"enter array elements";
for (i=0; i<n;i++)
{
cin>>a[i];
}
for(i=1;i<n;i++)
{
for(j=0;j<(n-i);j++)
if(a[j]>a[j+1])
{
tmp=a[j];
a[j]=a[j+1];
a[j+1] =tmp;
}
}
cout<<"array after bubble sort";
for(i=0;i<n;++i)
cout<<" "<<a[i];
return 0;
}