INSERTION

#include
#include
void insertion(long int [],int);//protype
int main()
{
      long int a[20]; int i,j,n;
printf("Program of insertion\n");
printf("enter the size of array\n");
scanf("%d",&n);
for(i=0;i {
scanf("%ld",&a[i]);
}
printf("before sorted\n\n");
for(i=0;i printf("%ld\t",a[i]);
insertion(a,n);//calling of insertion function
printf("\nsorted array by insertion method\n");
for(i=0;i {
printf("%ld\t",a[i]);
  }
getch();
return 0;
  }
void insertion(long int a[], int n)
{
      long int temp,i,j;
for(i=1;i {       temp=a[i];//make a temperoray variable.
for(j=i-1;j>=0 && temp        { a[j+1]=a[j];
}
  a[j+1]=temp;
  }

  }