#include<stdio.h>
//Program for Insertion Sorting
int main()
{
int i,j,k,N,a[100],temp;
printf(“Enter no. of elements you want to sort :\t”);
scanf(“%d”,&N);//Max. no. of elements
printf(“Enter %d elements you want to sort :\t”,N);
for(i=0;i<N;i++)
scanf(“%d”,(a+i));
printf(“\nBefore Sorting:\t”);
for(i=0;i<N;i++)
printf(“%d\t”,*(a+i));
//Sorting Process Start
for(i=1;i<N;i++)
for(j=0;j<i;j++)
if(a[i]<a[j])
{
temp = a[i];
for(k=i;k>j;k–)
{
a[k]=a[k-1];
}
a[j]=temp;
}
//Sorting Ends
printf(“\nAfter Sorting:\t”);
for(i=0;i<N;i++)
printf(“%d\t”,*(a+i));
return 0;
}