C program for sorting of numbers , C/C++ Programming

Assignment Help:

C Program for SORTING OF NUMBERS

 

main()

{

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

          clrscr();

          printf("ENTER THE MAXIMUM LIMIT: ");

          scanf("%d",&n);

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

          {

                   printf("ENTER %d ELEMENT: ",i);

 

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

          }

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

                   for(j=i+1;j<=n;j++)

                   {

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

                             {

                                      temp=a[i];

                                      a[i]=a[j];

                                      a[j]=temp;

                             }

                   }

          printf("\nTHE SORTED ELEMENTS ARE. \n");

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

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

          getch();

}

 

OUTPUT :

ENTER THE MAX. LIMIT: 5

ENTER 1 NO: 5

ENTER 2 NO: 8

ENTER 3 NO: 10

ENTER 4 NO: 1

ENTER 5 NO: 2

THE SORTED ELEMENTS ARE:

1 2 5 8 10

 


Related Discussions:- C program for sorting of numbers

Define a class to model a banking system, Explain a class to model a bankin...

Explain a class to model a banking system. The function members should allow initializing the data members, a query to facilitate for account and a facility to deposit and with

Write down the class listnode, Question: (a) Write down the class 'Li...

Question: (a) Write down the class 'ListNode' to contain the following:- (i) variable data of type Object (ii) variable next of type ListNode (iii)

Control structures in cpp, Control structures The control structures app...

Control structures The control structures appear in both structured programming languages as well as object oriented programming languages.  The three constructs used are: i)

Verifone pos offline mod vx670, Verifone pos offline mod vx670 Project D...

Verifone pos offline mod vx670 Project Description: I want a programmer who will build custom application for Offline VX670 to collect and save info+pin 1) Press the am

Define the modulo division operator in c language, Define the Modulo Divisi...

Define the Modulo Division Operator in c language? The C provides one more arithmetic operator % called as modulo division operator and this operator yields the remainder of an

Which constructor gets called while i create an array of , Which constructo...

Which constructor gets called while I create an array of Fred objects?

Explain public and private members, Public, Private and Protected members: ...

Public, Private and Protected members: Class members can either be declared in public','protected' or in the 'private' sections of the class. But as one of the features of OOP i

''c'' programme, Write a ''C'' program to accept any 3 digit integer number...

Write a ''C'' program to accept any 3 digit integer number from the keyboard and display the word equivalent representation of the given number.

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