C Program To Arrange Numbers In Descending Order

C Program To Arrange Numbers In Descending Order. If you are looking for sort the array in descending order program in C, here in this tutorial we will help you to learn how to write a c program to C program to arrange the given numbers in descending order.

C Program To Arrange Numbers In Descending Order

Learn how to write a c Program to arrange array elements in descending order. Writing descending order program in C can be done using various techniques but here in this program, we show how to write a c program to arrange numbers in descending order in a proper way. Happy coding.

C Program to Arrange Numbers in Descending Order Source Code

Just copy paste the below source code to arrange numbers in descending order in C compiler to test, how the source code works. Happy Learning.

/* C program to arrange numbers in descending order DescOrder.C */

#include <stdio.h>
 
void main ()
{
 //variable declaration
 int number[30];
 int i, j, a, n;

 //asking user to enter size of array 
 printf("Enter the value of N\n");
 scanf("%d", &n); //reading array size
 
 //asking user to enter array elements
 printf("Enter the numbers \n"); 
 for (i = 0; i < n; ++i)
  scanf("%d", &number[i]); //reading array elements

 /* Logic for sorting and checking */

 for (i = 0; i < n; ++i)
 {
   for (j = i + 1; j < n; ++j)
   {
    if (number[i] < number[j])
    {
     a = number[i];
     number[i] = number[j];
     number[j] = a;
   }
  }
 }
 
 printf("The numbers arranged in descending order are given below\n");
 for (i = 0; i < n; ++i)
 {
   printf("%d\n", number[i]); //printing numbers in descending order
 }
}

C Program to Arrange Numbers in Descending Order Output

Enter the value of N

3

Enter the numbers

5

23

16

The numbers arranged in descending order are given below

23

16

5

C PROGRAMMING EXAMPLES

  1. C Program to Add Days to Date
  2. C Program to Add Two Fractions
  3. C Program To Reverse A Number
  4. C Program to Find Maximum and Minimum Numbers
  5. C Program to Read a Text File
  6. C Program to Convert Decimal to Hexadecimal
  7. C Program to Convert Decimal to Binary
  8. C Program to Convert Celsius to Fahrenheit
  9. C Program To Find Absolute Value
  10. Ternary Operator Program in C
  11. C Program For Addition Table Using For Loop
  12. Denomination Program in C
  13. C Program to Print Multiplication Table 
  14. C Program Array with Example
  15. Binary Search in C Program Using Recursion
  16. Bubble Sort in C Using Pointers
  17. Bubble Sort Program in C Using Recursion
  18. Bubble Sort Program in C Using Array
  19. Bubble Sort Program in C Using Function
  20. Bubble Sort Program in C Using Linked List

Leave a Comment