#include<stdio.h>voidShellSort(int a[],int n){int i, j, increment, tmp;for(increment = n/2; increment >0; increment /=2){for(i = increment; i < n; i++){
tmp = a[i];for(j = i; j >= increment; j -= increment){if(tmp < a[j-increment])
a[j]= a[j-increment];elsebreak;}
a[j]= tmp;}}}intmain(){int i, n, a[10];printf("Enter the number of elements :: ");scanf("%d",&n);printf("Enter the elements :: ");for(i =0; i < n; i++){scanf("%d",&a[i]);}ShellSort(a,n);printf("The sorted elements are :: ");for(i =0; i < n; i++)printf("%d ",a[i]);printf("\n");return0;}
OUTPUT:
Enter the number of elements :: 6
Enter the elements :: 50 30 10 40 20 60
The sorted elements are :: 10 20 30 40 50 60