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

Assignment Help:

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();

}


Related Discussions:- Shell sort - c program

Luminous Jewels - The Polishing Game, Byteland county is very famous for lu...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

I want rss feed from emails, Project Description: I am trading binary op...

Project Description: I am trading binary options and need my signals that are sent to me via email to be sent to my followers via an RSS feed I have no idea how rss feeds imp

C program to print character array, Program to print character array : ...

Program to print character array : Write a program to print the character array by using string class functions. void main() {  char line[30];   int i=0;   clrsc

Function declarations and function definitions in cpp, FUNCTIONS It refe...

FUNCTIONS It refers to a subprogram that is meant to do a certain task. It is basically used to execute a set of operations and return information to the main or calling functio

Program for read a formal expression from standard input, Your program will...

Your program will read two kinds of data from two files: names and predicates. It will read a formal expression from standard input and check whether that expression is syntactical

Decode the code, By pressing ‘6’ (i.e. key’6’ one time) on the keypad, the ...

By pressing ‘6’ (i.e. key’6’ one time) on the keypad, the mobile shows ‘m’ on display screen in write text message area

I need file transfer solution, We move a high quantity of large Video files...

We move a high quantity of large Video files (200mb - 2 GB each) across the internet. We have a Linux server (ubuntu) hosted in a datacenter (1Gbps) operating an FTP server. Our

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd