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
In this worksheet you are asked to write three classes in C++: Lecture class, Course class and University class. The classes relate to each other in the way that a Course has many

coloring of elements in matrix form inm particular matrix.the color should not match with another color.

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

(a) Verify the values of the resistors with the following colour coding: (i) red-red-orange-silver (ii) orange-orange-black-blue-green (b) What is the value of a resistor

Write a ''C'' program to accept any 3 digit integer number from the keyboard and display the word equivalent representation of the given number.

A company needs 200 pencils per year . you cannot simply use this price as the cost of pencils two years from now. Because of inflation the cost is likely to be higher than it is

A: 1.      By using const protects you against programming errors which inadvertently alter data. 2.      By using const allows function to procedure const and non-const actu

Bit-wise Operators Some applications require operations to be done on dissimilar bits of a byte separately. Bit-wise operators offer a facility to do just that. There are vario

Temperature Conversions. Problems 28 through30generate temperature-conversion tables. Use the following equations that give relationships between temperatures in degrees Fahrenheit

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 #include float start_point,