#include<stdio.h>

main()
{
int a[50],i,j,n,t,key,item;
printf("Enter the size of the array:\n");
scanf("%d",&n);
printf("Enter elements into the array:");
for(i=0; i<n; i++)
{
scanf("%d",&a[i]);
}
for(i=1; i<n; i++)
{ j=i-1;
key=a[i];
while(a[j]>key&&j>-1)
{ a[j+1]=a[j];
j--;
}
a[j+1]=key;
}
printf("The sorted array is: ");
for(i=0; i<n; i++)
{
printf("%d\t",a[i]);
}
}
     
           
Note: Need to be arranged in compiler after copied
   

 OutPut:

Enter the size of the array: 5 Enter elements into the array:6 3 5 2 7 The sorted array is: 2 3 5 6 7