In this article I will share to you guys a shell sort program that I wrote using C programming language. I am using Dev C++ as my C++ compiler in writing this program.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
Here in Bacolod City I also accepting computer repair, networking and Arduino Project development at a very affordable price.
Sample Program Output
Program Lisiting
/* shell_sort.c
Author : Mr. Jake Rodriguez Pomperada,BSCS,MAED-IT
Tool : Dev C++ 5.11
Date : April 18, 2019 Thursday 10:53 AM
Website : www.jakerpomperada.com
Email : jake_pomperada@tup.edu.ph and jakerpomperada@gmail.com
Location : Bacolod City, Negros Occidental
*/
#include <stdio.h>
#include <stdlib.h>
void shellsort(int arr[], int num);
int main()
{
int items[1000], num=0,min=0,loc=0;
int c=0, b=0,change=0,j=0,temp=0;
system("cls");
printf("\n\n");
printf("\tShell Sort Program in C");
printf("\n\n");
printf("\tHow many items? : ");
scanf("%d", &num);
printf("\n\n");
for (c= 0; c < num; c++) {
printf("\tEnter item no. %d: ", c+1);
scanf("%d", &items[c]);
}
printf("\n\n");
printf("\tOriginal Arrangement of Numbers");
printf("\n\n");
for ( c = 0 ; c < num ; c++ ) {
printf("\t%d ",items[c]);
}
shellsort(items, num);
printf("\n\n");
printf("\tAsceding Order of Numbers");
printf("\n\n");
for ( c = 0 ; c < num ; c++ ) {
printf("\t%d ", items[c]);
}
printf("\n\n");
printf("\tEnd of Program");
printf("\n\n");
system("pause");
}
void shellsort(int arr[], int num)
{
int i, j, k, tmp;
for (i = num / 2; i > 0; i = i / 2)
{
for (j = i; j < num; j++)
{
for(k = j - i; k >= 0; k = k - i)
{
if (arr[k+i] >= arr[k])
break;
else
{
tmp = arr[k];
arr[k] = arr[k+i];
arr[k+i] = tmp;
}
}
}
}
}