#include<iostream.h> #include<conio.h> void main() { int a[10],b; cout<<"Enter the array: "<<endl; for (int i=0;i<10;i++) cin>>a[i]; //this will populate the array for (int i=0;i<10;i++) { for (int k=i+1;k<10;k++) { if (a[i]>a[k]) { b=a[k]; a[k]=a[i]; //this will compare each element of array with rest a[i]=b; } } } cout<<endl<<"Sorted array is: "; for (int i=0;i<10;i++) cout<<a[i]<<" "; //this will display the array getch(); }
Saturday, March 15, 2014
Ascending Sorting of Array
Ascending Sorting of Array
2014-03-15T19:16:00+05:00
Unknown
ascending|bubble sorting|C++|codesnippets|sorting|
Subscribe to:
Post Comments (Atom)