Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<conio.h>
  3.  
  4. void main()
  5. {
  6. int i,a[10],temp,j;
  7. clrscr();
  8. cout<<"Enter any 10 num in array: \n";
  9. for(i=0;i<=10;i++)
  10. {
  11. cin>>a[i];
  12. }
  13. cout<<"\nData before sorting: ";
  14. for(j=0;j<10;j++)
  15. {
  16. cout<<a[j];
  17. }
  18. for(i=0;i<=10;i++)
  19. {
  20. for(j=0;j<=10-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<<"\nData after sorting: ";
  31. for(j=0;j<10;j++)
  32. {
  33. cout<<a[j];
  34. }
  35. getch();
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement