Selection Sort

Selection Sort

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn C programming concepts. You can learn C language at your own speed and time. One can learn concepts of C language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Selection Sort
Selection Sort

Write a C program to Selection Sort

PROGRAM: Selection Sort

/* Selection Sort */
#include<stdio.h>

int main()
{
 int arr[10],i,j,k,t;
 printf("Please enter 10 values:\n");
 for(i=0;i<10;i++)
  scanf("%d",&arr[i]);
 
 for(i=0;i<10;i++)
 {
  k=i;
  for(j=i;j<10;j++)
  {
   if(a[k]>a[j])
    k=j;
  }
  if(k!=i)
  {
   t=a[k];
   a[k]=a[i];
   a[i]=t;
  }
 }
 
 printf("Sorted Array is:\n");
 for(i=0;i<10;i++)
  printf("%d\n",arr[i]);
 
 return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *