#include <stdio.h> main() { int arr[10]; int i, j, n , flag= 1, gap_size,temp; clrscr(); printf("\n Enter the number of elements in the array: "); scanf ("%d",&n); printf("\n Enter numbers: "); for(i= 0;i< n;i++) { scanf("%d",&arr[i]); } while(flag == 1 || gap_size>1) { flag=0; gap_size=(gap_size+1)/2; for(i=0;i<(n-gap_size);i++) { if(arr[i+gap_size]>arr[i]) { temp = arr[i+gap_size]; arr[i+gap_size]=arr[i]; arr[i] = temp; } } } printf("\n The sorted array is: \n"); for(i=0;i<n;i++) { printf ("\t%d\t", arr [i]); } getch(); }