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
need an expert programmer to finish coding the requirements from the assignment withen 4 hrs

how to create a flowchart? can you help me in my assignment about flowcharting ....


How would I use variables of a C++ object within a Lua function, and then call the Lua function from C++ code?

You are given a collection of words, say as in a dictionary. You can represent it in the following compressed form: the first word will be followed by a sequence of a pair of numbe

char P[100]; double X=533.8*22500; sprintf(P,"%f %u",X,(unsigned int)X); MessageBox(P,"SSS"); //12010500.000 12010499

O v e r l o a d i n g U n a r y Op e r a t o r s Us i n g F r i e n d F u n c t i o n cl a ss s i g n { i n t a ,

Sine function computation

smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

# c pragram TO count the number of occurances of the string in nth padovan''s string program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : pa