Write a program to arrange the ‘n’ numbers stored in the array in ascending and descending order.

Here is source code of the C program to sort the array in an descending order. The program is successfully compiled and tested using Turbo C compiler in windows environment. The program output is also shown below.
  1.    /*
  2.     * C program to accept a set of numbers and arrange them
  3.     * in a descending order
  4.     */
  5.  
  6.     #include <stdio.h>
  7.     void main ()
  8.     {
  9.  
  10.         int number[30];
  11.  
  12.         int i, j, a, n;
  13.         printf("Enter the value of N\n");
  14.         scanf("%d", &n);
  15.  
  16.         printf("Enter the numbers \n");
  17.         for (i = 0; i < n; ++i)
  18.          scanf("%d", &number[i]);
  19.  
  20.         /*  sorting begins ... */
  21.  
  22.         for (i = 0; i < n; ++i) 
  23.         {
  24.             for (j = i + 1; j < n; ++j) 
  25.             {
  26.                 if (number[i] < number[j]) 
  27.                 {
  28.                     a = number[i];
  29.                     number[i] = number[j];
  30.                     number[j] = a;
  31.                 }
  32.             }
  33.         }
  34.  
  35.         printf("The numbers arranged in descending order are given below\n");
  36.  
  37.         for (i = 0; i < n; ++i) 
  38.         {
  39.             printf("%d\n", number[i]);
  40.         }
  41.  
  42.     }
Program Explanation
1. Declare an array of some fixed capacity, lets say 30.
2. From users, take a number N as input, which will indicate the number of elements in the array (N <= maximum capacity)
3. Iterating through for loops (from [0 to N) ), take integers as input from user and print them. These input are the elements of the array.
4. Now, create a nested for loop with i and j as iterators.
5. Start the sorting in descending order by extracting each element at position i of outer loop.
6. This element is being compared to every element from position i+1 to size-1 (means all elements present below this extracted element)
7. In case any the extracted element is smaller than the element below it, then these two interchange their position, else the loop continues.
8. After this nested loop gets executed, we get all the elements of the array sorted in descending order.