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
#include #include #include #include #include class Employee { private: char *Name; //Set them as pointers... int IdNumber; char *Department; char *Position; public: voi

How to Create A Data File? A data file should be created before it can be processed. A stream-oriented data file is able to be created in two ways. One is to create the file st

Read numbers form user and place them in array: Program is to read a group numbers of numbers form user and place them in array type of float and sort them void sort(floa

lcm program.

having 2 arrays and 3killograms of pebbles are needed converting an area of 1 square meter the rate of pebble is $5 per killograms

Project Description: I want a simple program that will spoof my hardware id. I should be able to prepare the id to spoof to in the program and press "random" button to spoof to


Variable Declaration This declaration of variables in the C language is permitted only in the starting of their block, prior to executable program statements. In C++ declaratio

Define some features of register storage class in c program? The feature of variable defined to be of register type all as follows: Storage - CPU registers Default initia

Problem: (a) A GUI can contain text-fields, buttons, and other labels. A button usually triggers an event on the GUI. Explain the different processes in registering an event