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
Need an indicator Project Description: Need an indicator which indicates target and trailing sl after entering trades. Skills required are C Programming, C++ Programming,


Pointer Types Pointer holds the address of an object, permitting for the indirect manipulation of that object. They are used in creating linked data structures like lists, tree

A virtual function permits derived classes to replace the implementation given by the base class. The compiler makes sure the replacement is always known as whenever the object in

Question 1 Create a class String which stores a string value. Overload ++ operator which converts the characters of the string to uppercase (toupper() library function of "ctype.h

Write a function that has an int parameter n, makes an integer mask having the bit 1 at the nth place from the rightmost bit, and returns the mask. For example, when n = 5 is passe

write a java program padovan string program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : package test.padovanstring; public class Pado

C Program to copy the contents of a file: void main()    {   ifstream fin("input.txt");   ofstream fout("output.txt");   char ch;   while (fin)       {

A: They present a degree of freedom in the interface design options. Member functions & friend functions are equally privileged (100% vested). The major difference is that a fri