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
A game is played with three piles of stones and two players. At her turn, a player removes one or more stones from the piles. However, if she takes stones from more than one pile,

Q: however shouldn't I always use a printOn() method instead of a friend function? A: No. The usual cause people wish to always use a printOn() method instead of  a friend fu


given integer ''n'' and permutation of numbers 1,2,..n-1, c program to print permutation that lexicograghically precedes given input permutation if permutation is least print input

Write a C program to compute the factorial of  5 i.e 1x2x3x4x5 etc #include stdio.h   void main()   {   char promt;      int factor;   factor = 1*2*3*4*5;   printf("The fac

how yo use the friend function?


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

Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given

Object Oriented Programming Paradigm: For OOP, Paradigm is a standard set.  The OOP will help to develop software in modules, which will be integrated later as a full packag