answersLogoWhite

0

Assume your numbers are into an array. Then write any user-defined function implementing any kind of sorting. I am giving example of bubble sort.

  1. void bubble(int a[],int n){
  2. int i,j,t;
  3. for(i=n-2;i>=0;i--){
  4. for(j=0;j<=i;j++){
  5. if(a[j]>a[j+1]){
  6. t=a[j];
  7. a[j]=a[j+1];
  8. a[j+1]=t;
  9. }
  10. }
  11. }
  12. }
User Avatar

Wiki User

14y ago

What else can I help you with?

Continue Learning about Engineering

Ascending order program for java?

public class BubbleSortAscendingOrderDemo { public static void main(String a[]) { //Numbers which need to be sorted int numbers[] = {23,5,23,1,7,12,3,34,0}; //Displaying the numbers before sorting System.out.print("Before sorting, numbers are "); for(int i = 0; i &lt; numbers.length; i++) { System.out.print(numbers[i]+" "); } System.out.println(); //Sorting in ascending order using bubble sort bubbleSortInAscendingOrder(numbers); //Displaying the numbers after sorting System.out.print("Before sorting, numbers are "); for(int i = 0; i &lt; numbers.length; i++) { System.out.print(numbers[i]+" "); } }


How do you sort an array of numbers?

Use a sorting algorithm. There are a bewildering number of sorting algorithms, both stable and unstable. To sort numbers, an unstable sort suffices. The algorithm you use will depend on how many numbers need to be sorted (a small or a large set), however a hybrid algorithm (a combination of two or more algorithms) can cater for both. Introsort (unstable) and timsort (stable) are the two most common hybrid sorting algorithms.


Sum of n numbers in shell programming?

2 4 6


What does reverse sorting do?

Reverse sorting arranges a list of items in descending order, meaning the largest or highest values come first and the smallest or lowest values come last. This can be applied to various types of data, such as numbers, strings, or dates, depending on the context. For example, reverse sorting a list of numbers would display the highest number at the top. It is often used to prioritize or highlight the most significant items in a dataset.


What is the code for arranging numbers in c language?

That depends on the sorting algorithm you'd like to use. Usually, Quick-sort is good enough for your purposes, but if your application needs to be fast, you might want to read some documents about sorting.

Related Questions

Ascending order program for java?

public class BubbleSortAscendingOrderDemo { public static void main(String a[]) { //Numbers which need to be sorted int numbers[] = {23,5,23,1,7,12,3,34,0}; //Displaying the numbers before sorting System.out.print("Before sorting, numbers are "); for(int i = 0; i &lt; numbers.length; i++) { System.out.print(numbers[i]+" "); } System.out.println(); //Sorting in ascending order using bubble sort bubbleSortInAscendingOrder(numbers); //Displaying the numbers after sorting System.out.print("Before sorting, numbers are "); for(int i = 0; i &lt; numbers.length; i++) { System.out.print(numbers[i]+" "); } }


What Program that lists telephone numbers in numeric order or street address?

In programming this could be achieved using a numeric bubble sort. Excel allows this type of sorting to be used.


What is is sorting?

sorting can be described as the arrangement of text/numbers either in Ascending or Descending order


When given a list of numbers what are the steps to put them greatest to least?

There are several different algorithms for sorting numbers by size. ?The steps to take will depend on which algorithm you wish to use.There are several different algorithms for sorting numbers by size. ?The steps to take will depend on which algorithm you wish to use.There are several different algorithms for sorting numbers by size. ?The steps to take will depend on which algorithm you wish to use.There are several different algorithms for sorting numbers by size. ?The steps to take will depend on which algorithm you wish to use.


What is internal and external sorting techniques?

Internal sorting it means we are arranging the number within the array only which is in computer primary memory. External sorting it is the sorting of numbers from the external file by reading it from secondary memory.


Sorting an array of numbers in java?

here you will a good example on java sorting algorithm application http://javacodespot.blogspot.com/2010/08/java-sorting-animations.html http://javacodespot.blogspot.com/


Why you use stem and leaf plot in data sorting?

we use sem and leaf plot in data sorting when there are lare amounts of numbers to anyalyze.


How do you sort an array of numbers?

Use a sorting algorithm. There are a bewildering number of sorting algorithms, both stable and unstable. To sort numbers, an unstable sort suffices. The algorithm you use will depend on how many numbers need to be sorted (a small or a large set), however a hybrid algorithm (a combination of two or more algorithms) can cater for both. Introsort (unstable) and timsort (stable) are the two most common hybrid sorting algorithms.


How do write sorting of numbers using microprocessor?

There are several methods available to sort numbers. A simple way to program sorting is the so-called "bubble-sort". This is inefficient for larger lists of numbers; in which case it is more convenient to use one of the faster algorithms, for example, "quick-sort".


What is specific function?

A specific function refers to a function that has a distinct, well-defined purpose or task within a system or program. It is typically designed to perform a specific operation or calculation, such as sorting data, generating random numbers, or formatting text. The use of specific functions helps to streamline code and improve clarity and organization in programming.


What is the meaning of the numbers in your zip-code?

They assist in the sorting of mail. To help pinpoint where you're located.


How do you order a set of real numbers?

To order a set of real numbers, you compare each number based on their value on the number line. You start by identifying the smallest number and place it first, then continue selecting the next smallest until all numbers are arranged in ascending order. For descending order, you do the opposite, starting from the largest number down to the smallest. This process can be done manually or using sorting algorithms in programming.


What are the key differences between radix sort and quicksort in terms of efficiency and performance?

Radix sort and quicksort are both sorting algorithms, but they differ in their approach and efficiency. Radix sort is a non-comparative sorting algorithm that sorts numbers by their individual digits, making it efficient for sorting large numbers. Quicksort, on the other hand, is a comparative sorting algorithm that divides the list into smaller sublists based on a pivot element, making it efficient for sorting smaller lists. In terms of performance, radix sort has a time complexity of O(nk), where n is the number of elements and k is the number of digits, while quicksort has an average time complexity of O(n log n). Overall, radix sort is more efficient for sorting large numbers with a fixed number of digits, while quicksort is more efficient for general-purpose sorting.


Can you use expression?

Yes, you can use expressions in various contexts, such as mathematics, programming, and language. In mathematics, expressions are combinations of numbers, variables, and operators that represent a value. In programming, expressions evaluate to a value and can include variables, functions, and operators. Additionally, in language, expressions can convey thoughts or emotions through words and phrases.


Is ascending the same as sorting for A - Z?

Yes. Ascending starts at A or goes from lower to higher in the case of numbers.


C program for sorting the numbers?

C program for sorting the numbers is very basic, start writing it and if you are having problems, post your program here and a description of the problem and you will be helped. If you are taking a computer course, how do you expect to pass exams if you have plagiarized someone else work for your assignments.


Why does palm desert have a dash for there address?

According to the local post office their sorting equipment has difficulty sorting mail if the address has a "-" dash between the numbers and have asked people to please NOT put the dash in the address.


How do you arrange numbers in ascending order in qbasic programming?

To arrange numbers in ascending order in QBASIC, you can use a simple sorting algorithm like bubble sort. First, store the numbers in an array. Then, repeatedly compare adjacent elements and swap them if they are in the wrong order until the entire array is sorted. Here's a basic example: DIM numbers(5) AS INTEGER ' (Assume numbers are already populated) FOR i = 0 TO 4 FOR j = 0 TO 4 - i - 1 IF numbers(j) &gt; numbers(j + 1) THEN SWAP numbers(j), numbers(j + 1) END IF NEXT j NEXT i This will sort the array numbers in ascending order.


What is sort ascending?

Sorting in ascending order refers to arranging a set of data from the smallest to the largest value. This can apply to numbers, letters, or dates, where numbers are sorted from lowest to highest, letters from A to Z, and dates from the earliest to the latest. For example, if you have the numbers 3, 1, and 2, sorting them in ascending order would result in 1, 2, and 3.


What can you not do with numbers represented in ascii?

Numbers represented in ASCII cannot be directly used for mathematical operations, as they are stored as text rather than numerical values. Consequently, you cannot perform arithmetic calculations, comparisons, or other numerical functions without first converting them to an appropriate numeric data type. Additionally, sorting or manipulating the numbers as integers or floats is not possible until they are parsed from their ASCII representation.