answersLogoWhite

0


Best Answer

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

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Sorting numbers using user-defined functions in C programming?
Write your answer...
Submit
Still have questions?
magnify glass
imp
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


Difference between internal and external sorting?

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.


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


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.


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.


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 the meaning of the numbers in your zip-code?

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


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.


What is a Function in Trigonometry?

There are two types of functions in trigonometry: there are functions that are mappings from angles to real numbers, and there are functions that are mappings from real numbers to angles. In some cases, the domains or ranges of the functions need to be restricted.