Program of insertion sort in C programming language
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],j,i,key;
clrscr();
printf("Enter the elements of the array\n");
for(i=0;i<10;i++)
{ scanf("%d",&a[i]);
}
for(j=1;j<10;j++)
{
key= a[j];
i=j-1;
while(i>=0 && a[i]>key)
{
a[i+1]=a[i];
i--;
}
a[i+1]=key;
}
printf("Sorted list\n");
for(i=0;i<10;i++)
{
printf("%d\n",a[i]);
}
getch();
}

0 Comments
Have any query? Want any type of module?
Please comment it down and let me know.