Professional Documents
Culture Documents
Bubble Sort
Bubble Sort
int b[5]={15,5,10,20,7};
int temp;
int n=5;
for(int i=0;i<n-1;i++)
cout<<"inside n is "<<n<<endl;
for(int r=0;r<n-1-i;r++)
if(b[r]>b[r+1])
temp=b[r];
b[r]=b[r+1];
b[r+1]=temp;
for(int j=0;j<n;j++)
cout<<b[j]<<endl;
}
for(int k=4;k>=0;k--)
cout<<b[k]<<endl;