Introducing Radical.sh

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

Shell Sort in C++

#include <iostream>
using namespace std;

int main(void)
{
    int array[5]={4,5,2,3,6},i1=0;
    
        int i, j, increment, temp,number_of_elements=5;
        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;
                }
        }
  cout<<"After Sorting:";
    for(i1=0;i1<5;i1++)
    {cout<<array[i1];
    }
   
}