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

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

 

Posted Date: 9/10/2012 2:15:28 AM | Location : United States







Related Discussions:- C program for sorting of numbers , Assignment Help, Ask Question on C program for sorting of numbers , Get Answer, Expert's Help, C program for sorting of numbers Discussions

Write discussion on C program for sorting of numbers
Your posts are moderated
Related Questions
how we can code in c++ for assignment problem (operation research) method to mkinimization and mamization

one of the segments is showing compilation error...

A: Provide a friend operator class Base { public: friend std::ostream& operator ... protected: virtual void printOn(std::ostream& o) const; }; inline std::ostr

B-tree: A B-tree is an also called balanced m-way tree. A node of the tree may have many records or key and pointers to children. It is also called as the balanced sort tree. It s

How to write an inline class member function In addition to global functions, you may request that non-static member functions of a class be inlined.  The normal method of doin

#questio c++ program for drawing thick line

I need a client-server architecture program for windows OS (minimum support: Win 7),. the agent program will run as a background process and perform certain tasks every X time, and

Develop Custom Mql4 Code/Fxdreema block Project Description: I need the subsequent code written in mql4 and integrated as custom block(s) in fxdreema: for each trade: C

What is the difference between JavaScript and PHP? The difference lies with the execution of languages. PHP is server side scripting language, which means that it cannot intera

write a program to solve e^x