VOOZH about

URL: https://www.geeksforgeeks.org/c/c-program-to-sort-the-elements-of-an-array-in-descending-order/

⇱ C Program to Sort the Elements of an Array in Descending Order - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C Program to Sort the Elements of an Array in Descending Order

Last Updated : 23 Jul, 2025

Sort an array in descending order means arranging the elements in such a way that the largest element at first place, second largest at second place and so on. In this article, we will learn different ways to sort an array in descending order in C.

The simplest method to sort the array in descending order is by using the in-built library function qsort(). Let's take a look at an example:


Output
5 4 3 2 1 

qsort() function uses quicksort algorithm and needs a comparator function for guiding it to sort the array in descending order.

C language only provides the built-in implementation of quick sort algorithm. If you want to use other sorting algorithm apart from quicksort, you have to manually implement it as shown:

Using Selection Sort

Selection sort is a simple sorting algorithm that repeatedly finds the maximum element from the unsorted part of the array and places it at its position in the sorted part of the array until the complete array is sorted.


Output
5 4 3 2 1 

Using Bubble Sort

In Bubble Sort Algorithm, we repeatedly swap adjacent elements if they are in the wrong order. This process is repeated until the array is sorted in descending order.


Output
5 4 3 2 1 
Comment