Professional Documents
Culture Documents
of elements in list\n"; cin>>n; cout<<"\nEnter array elements\n"; for(int i=0;i<n;++i) { cin>>a[i];} for(i=0;i<n;i++) { small=a[i]; for(int j=i+1;j<size;j++) { if(a[j]<small) {small=a[j];pos=j;} } temp=a[i]; a[i]=a[pos]; a[pos]=temp; } cout<<"The sorted array is as shown below:-\n"; for(i=0;i<n;i++) {cout<<a[i]<<" ";} getch(); } Output:Enter th no. of elements in list 5 Enter array elements 56 78 45 65 32 The sorted array is as shown below:32 45 56 65 78