Shell sort - c program, C/C++ Programming

Shell sort - C Program:

Write a program to define shell sort.

void main()

{                  //program for sorting by select sort

int a[20],i,k,j,n;

 

clrscr();

 

printf("How many nos are to be sorted\n");

scanf("%d",&n);

 

for (i=0;i<=n-1;i++)

{

printf("Enter the value of %d no\t",i+1);

scanf("%d",&a[i]);

}

printf("Make sure !Are your values read correctly?\n");

 

for (i=0;i<=n-1;i++)

printf("%d \n",a[i]);

 

for (i=0;i<=n-1;i++)   //In select sort we consider the 1 st element &

for (j=i+1;j<=n-1;j++) //compare it with the remaining in the 1st step

   {                   //&swaping is done next considering 2nd element etc.

     if (a[i] >= a[j])

      {

                k=a[i];

                a[i]=a[j];

                a[j]=k;

       }

   }

 

printf("The sorted data is\n");

                for (j=0;j<=n -1;j++)

                printf("%d\n",a[j]);

getch();

}

Posted Date: 10/19/2012 3:05:52 AM | Location : United States







Related Discussions:- Shell sort - c program, Assignment Help, Ask Question on Shell sort - c program, Get Answer, Expert's Help, Shell sort - c program Discussions

Write discussion on Shell sort - c program
Your posts are moderated
Related Questions
Explain Formatted Input Output with File Pointer? Likewise there are equivalents to the functions scanf and printf which write or read data to files. These are called fscanf a

F u nction Returning Object: This program is like to the previous program except the function returns object.  The main rule to be remembered is the function returning obj

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b


##question.A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string co   program in jav

Why should I employ new instead of truthful old malloc()? A: Constructors/destructors, type safety, overridability. Constructors/destructors: unlike malloc(sizeof(Fred)), new

C Program to check FACTORIAL   main() {             int i,j,m,fact,sum=0;           clrscr();           printf("ENTER THE NO.: ");           scanf("%d",&m);


Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.

I am seeking a developer to create a mobile game for me. I want an endless runner game with simple controls. The game needs to be a 3D game in a 2D view. The graphics and animation