Praveen | Typing Speed Test is a very useful Software available for free Download.

C Programs to Insertion Sort

      Insertion sorting to sort numbers, And arrange them in ascending order or descending order. Insertion  sorting in descending order means one element to check any other elements of sequentially, if selected number is greater then to exchange positions of numbers, Otherwise continue to perform the specific operations.


Selection sorting in Descending order C programming code

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


void main()
{
   int i, j, a[10], n, k, temp;
  clrscr();
  printf("\n enter the series of Number ");
  scanf("%d",&n);
  for( i = 0 ; i < n ; i++ )
   {
      printf("\n enter the %d no. ",i+1);
      scanf("%d",&a[i]);
   }
  for( i = 1 ; i < n ; i++ )
   {
      temp=a[i];
      j=i-1 ;
      for( j = i-1; temp > a[j] && j >= 0 ; j-- )
      {
         a[j+1]=a[j];
      }
      a[j+1]=temp;
    }
  printf("\n Sorted order is->");
  for( i = 0 ; i < n ; i++ )
   {
      printf(" %d,",a[i]);
   }
  getch();
}


Output:-