Bubble Sort program in C++

  1. #include <iostream.h>  
  2. #include <conio.h>  
  3. void main()  
  4. {  
  5. clrscr(); int h,m,n;  
  6. int a[6]={50,40,45,90,35,70};  
  7. for(int k=0;k<=4;k++){  
  8. cout<<"Phase No. "<<k+1<<"Starts from here : ";  
  9. for(int j=0;j<=4;j++)  
  10. {  
  11. for(int p=j;p<=j;p++)  
  12. { h=a[j];n=a[j+1];  
  13. if(a[j]>a[j+1])  
  14. { a[j+1]=h;  
  15. a[j]=n;}}  
  16. for(int i=0;i<=5;i++)  
  17. cout<<a[i];  
  18. cout<<endl;  
  19. } }  
  20. getch();  
  21. }