SELECTION SORT PROGRAM

SELECTION SORT
#include<stdio.h>
#include<conio.h>


void main()
{
  int size, i, j, temp, a[100];
  clrscr();

  printf("Enter the size of the List: ");
  scanf("%d", &size);

  printf("Enter %d integer values: ",size);
  for(i=0; i<size; i++)
      scanf("%d",&a[i]);

  for(i=0; i<size; i++)
{
      for(j=i+1; j<size; j++)
     {
           if(a[i] > a[j])
           {
               temp=a[i];
               a[i]=a[j];
               a[j]=temp;
           }
      }
  }

  printf("Array after sorting is: ");
  for(i=0; i<size; i++)
      printf(" %d",a[i]);

  getch();

}
Share on Google Plus
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment