selection sorting technique.

●) program to implement selection sort in c.         language. 

#include<stdio.h>
#include<conio.h>
void main()
{
 int arr[20],N,p,i,j,t;
 clrscr();
 printf("Enter the size of array=");
 scanf("%d",&N);
 printf("Enter the elements=");
 for(p=0; p<N; p++)
 {
 scanf("%d",&arr[p]);
 }
printf("before sorting elements are=");
for(p=0; p<N; p++)
{
 printf("%d\t",arr[p]);
}
for(i=0; i<N-1; i++)
{
  for(j=i+1; j<N; j++)
   {
      if(arr[i]>arr[j])
      {
        t=arr[j];
        arr[j]=arr[i];
        arr[i]=t;
      }
   }
}
printf("the sorted array elements are=\n");
for(p=0; p<N; p++)
{
  printf("%d\t",arr[p]);
}
getch();
}

■》Output->
       


Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.