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
write aprogram in c++ to overload +,-,=,++ operator using unary and friend function in a single program

processing two jobs through 2 machine


Need assignment help What's the order that local objects are destructed?

I need help with virtual memory manager implementation in C

Asks the user for an integer. if the number is less than 21, ask them for a number again; repeat this until you get a number bigger than 20. 20 is not an acceptable number. Once yo

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

Write a simple telephone book program that stores the names and phone numbers of your friends/acquaintances in a file. Your program should have the abilities to: a. Add entries (na

Write a recursive function recursiveMin that takes an integer array, a starting subscript and an ending subscript as arguments, and returns the smallest element in the array. The f

A: No. (Excluding if you have an old compiler, you might have to force the new operator to throw an exception if it runs out of memory.) This turns out to be a real pain to alwa