//How to Sort array in c++ using Bubble sort.
#include<iostream.h>
#include<iostream.h>
#include<conio.h>
void main()
{
int a[40],n,i,t,k;
clrscr();
cout<<endl<<"Enter the no. of element in the array: ";
cin>>n;
cout<<endl<<"Enter the values of "<<n<<" elements: ";
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(k=0;k<n-1;k++)
{
for(i=0;i<n-1-k;i++)
{
if(a[i]>a[i+1])
{
t=a[i];
a[i]=a[i+1];
a[i+1]=t;
}
}
}
cout<<endl<<"The sorted array is:";
for(i=0;i<n;i++)
{
cout<<endl<<a[i];
}
getch();
}