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

Is probable to encompass virtual constructor? if yes, Is it probable to enc...

Is it probable to encompass Virtual Constructor? If yes, how? If not, Why?

Source code, processing two jobs through 2 machine

processing two jobs through 2 machine

Create an array of strings, Create an array of Strings and fill it with som...

Create an array of Strings and fill it with some interesting text, such as vacation destinations, album names, or weapon names from a CRPG. Display three elements of the array on t

C code, how can i easily make a program?

how can i easily make a program?

Create a custom calculator program, //Create a custom calculator program ca...

//Create a custom calculator program capable of reading the input stream of an expression //and make basic computations to provide answer. //Your program will ask the user to

COMPILER DESIGN, Compiler Design - Limit In The Method Instructions

Compiler Design - Limit In The Method Instructions

Write a program in c++ to read n numbers in an array, Problem Write a p...

Problem Write a program in C++ to read N numbers in an array, the user should be able to search a particular number in the array using sequential search algorithm. Writing a

Where php basically used, Why many companies are switching their current bu...

Why many companies are switching their current business language to PHP? Where PHP basically used? PHP is rapidly gaining popularity and numerous companies are switching their

Pro, i need to do my home work

i need to do my home work

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