0
1.2kviews
Write a program in C to implement Insertion Sort
1 Answer
0
2views
    #include<stdio.h>
    #include<conio.h>

    void insertion(int a[],int n)
    {
      int i,j,x,k;
      for(i=1;i<=n-1;i++)
      {  x=a[i];
         for(j=i;a[j-1]>x && j>0;j=j-1)
         {
           a[j]=a[j-1];
         }
         a[j]=x;
         printf("\n\n The array after pass no.%d: ",i);
         for(k=0;k<=n-1;k++)
         {
           printf("%4d",a[k]);
         }
      }//end of outer for loop.
    } //end of insertion function.

    void main()
       {
         int a[1000],n,i;
         printf("\n\nEnter an integer value for …

Create a free account to keep reading this post.

and 2 others joined a min ago.

Please log in to add an answer.