Selection sort - c program, C/C++ Programming

Selection sort - C program:

Write a program to define a selection sort.

void main()

 {

  clrscr();

  int a[100],ch,n;

  cout<<"enter the limit for the array : ";

  cin>>n;

  for (int i=0;i

                {

                cout<<"enter element "<

                cin>>a[i];

                }

                clrscr();

                cout<<"1. selection sorting"<

                ssort(a,n);

                 }

 }

 

void ssort(int a[100],int n)

 {

  clrscr();

  int i,min,po,j,t;

  for(i=0; i

                {

                min=a[i];

                po=i;

                 for (j=i+1; j

                {

                if (a[j]

                 {

                  min=a[j];

                  po=j;

                 }

                }

                   t=a[po];

                   a[po]=a[i];

                   a[i]=t;

                }

                cout<<" sorted arrays by selection "<<"\n\n";

                for(i=0;i

                cout<

                getch();

}

Posted Date: 10/19/2012 3:10:44 AM | Location : United States







Related Discussions:- Selection sort - c program, Assignment Help, Ask Question on Selection sort - c program, Get Answer, Expert's Help, Selection sort - c program Discussions

Write discussion on Selection sort - c program
Your posts are moderated
Related Questions
Define the Data Type Qualifiers in c Language? 1. const 2. volatile const: The const qualifier is used to tell C that the variable value can't change after initialization.

Develop a C++ program that uses a while to determine the gross pay (in Dollars) for each of several employees. The company pays “straight-time” for the first 40 hours worked by ea

wap to calculatethe volume of cone,cylinderand sphere

Ask questioGiven an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. I

The program must use the file named on the command line as its input file. Suppose the program is named pdbtool. Then if the user types pdbtool 1A36.pdb the program must read the d

how much is it to fix a small data struct in a sorted list that pass itemtypes. all the code is written just logical errors

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

We have used logic symbols in the past, but not really though about the actual real devices. Semiconductor companies have taken the logic symbols are manufactured them into logic f

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4