Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Shell Sort in C

#include  <stdio.h>

int main(void)
{
    int array[5]={4,5,2,3,6},i1=0;
    ShellSort(array,5);
printf("After Sorting:");
    for(i1=0;i1<5;i1++)
    {printf("%d",array[i1]);
    }
    return 0;
}
void ShellSort(int *array, int number_of_elements)
{
        int i, j, increment, temp;
        for(increment = number_of_elements/2;increment > 0; increment /= 2)
        {
                for(i = increment; i<number_of_elements; i++)
                {
                        temp = array[i];
                        for(j = i; j >= increment ;j-=increment)
                        {
                                if(temp < array[j-increment])
                                {
                                        array[j] = array[j-increment];
                                }
                                else
                                {
                                        break;
                                }
                        }
                        array[j] = temp;
                }
        }
}