Start New Discussion within our **Software Development Community** # Shell sort

```
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,j,gap,temp,a[10];
clrscr();
printf("How many numbers:=");
scanf("%d",&n);
printf("Enter %d numbers\n\n",n);
for(i=0;i<n;i++)
{
printf("Enter a[%d]:",i);
scanf("\n%d",&a);
}
for(gap=n/2;gap>0;gap=gap/2)
{
for(i=0;i<n;i=i+gap)
{
temp=a;
for(j=i;j>0&&a[j-gap]>temp;j=j-gap)
{
a[j]=a[j-gap];
}
a[j]=temp;
}
}
printf("Done with sort\n");
for(i=0;i<n;i++)
printf("%d\n",a);
getch();
}
```