Write a program to sort elements of array (bubble Sorting)

Size of array is taken from user.. Elemnts are entered by user.. Elements are sorted in ascending order..

Select To use this code as it is.. select and copy paste this code into code.cpp file :)
  1. #include<conio.h>

  2. #include<iostream.h>

  3. void main()

  4. {

  5. clrscr();

  6. int a[100],i,n,j,temp;

  7. cout<<"How many element: ";

  8. cin>>n;

  9. cout<<"Enter the elements of array: "<<endl;

  10. for(i=0;i<n;i++)

  11. cin>>a[i];

  12. cout<<"The elements of array Before Sorting: "<<endl;

  13. //Coding by: Snehil Khanor

  14. //http://WapCPP.blogspot.com

  15. for(i=0;i<n;i++)

  16. cout<<a[i]<<" ";

  17. cout<<endl;

  18. for(i=0;i<n;i++)

  19. {

  20. for(j=0;j<n-1-i;j++)

  21. {

  22. if(a[j]>a[j+1])

  23. {

  24. temp=a[j];

  25. a[j]=a[j+1];

  26. a[j+1]=temp;

  27. }

  28. }

  29. }

  30. cout<<"Elements of array After Sorting: "<<endl;

  31. for(i=0;i<n;i++)

  32. cout<<a[i]<<" ";

  33. getch();

  34. }

Check out this stream