Search Techno Talk

Sorting in C++

Posted 5:11 AM by Sobia in Labels: , ,
“Program For Inputting 10 Numbers and then Displaying them in Sorted order” /*---> #include #include const int max=10; void sort(int arr[], int size); void swap(int& x, int& y); void main() { clrscr(); int num[10]; cout<<"Enter any 10 numbers:\n"; for (int i=0; i<10;>>num[i]; cout<<"\nThe sorted List is:\n"; sort(num,max); cout<for(i=0; i<10;>getch(); } void sort(int arr[],int size) { int first,last,comp; for (first=0; first{ last=first; for (comp=first+1; compif (arr[comp]last=comp; swap(arr[first],arr[last]); } } void swap(int& x, int& y) { int temp; temp=x; x=y; y=temp; } <-----*\


0 comment(s) to... “Sorting in C++”

0 comments:

Post a Comment

Google Groups
Subscribe to Techno Talk
Email:
Visit this group