/***********************************/
/*PROGRAM TO PREFORM INSERTION SORT*/
/***********************************/
#include < stdio.h>
#include < conio.h>
#define INF -999
void main()
{
    int a[10],n,i,j,temp;
    clrscr();
    a[0]=INF;
    printf("Enter the size of array: ");
    scanf( "%d",&n);
    printf("\nEnter the elements of array:\n");
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=2;i<=n;i++)
    {
        temp=a[i];
        j=i-1;
        while(temp        {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=temp;
    }
    printf("\nAfter sorting the elements of array are:\n");
    for(i=1;i<=n;i++)
    {
        printf("%d ",a[i]);
    }
    getch();
}