C++ Programming Code Examples C++ > Arrays and Matrices Code Examples Program to Sort Elements of Array in Ascending Order Program to Sort Elements of Array in Ascending Order Sort an array elements means arrange elements of array in Ascending Order and Descending Order. You can easily sort all elements using bubble sort. #include<iostream.h> #include<conio.h> void main() { int x,a[10],temp,j; clrscr(); cout<<"Enter any 10 num in array: \n"; for(x=0;x<=10;x++) { cin>>a[x]; } cout<<"\nData before sorting: "; for(j=0;j<10;j++) { cout<<a[j]; } for(x=0;x<=10;x++) { for(j=0;j<=10-x;j++) { if(a[j]>a[j+1]) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } cout<<"\nData after sorting: "; for(j=0;j<10;j++) { cout<<a[j]; } getch(); }