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
- C Program to Add Days to Date
- C Program to Add Two Fractions
- C Program To Reverse A Number
- C Program to Find Maximum and Minimum Numbers
- C Program to Read a Text File
- C Program to Convert Decimal to Hexadecimal
- C Program to Convert Decimal to Binary
- C Program to Convert Celsius to Fahrenheit
- C Program To Find Absolute Value
- Ternary Operator Program in C
- C Program For Addition Table Using For Loop
- Denomination Program in C
- C Program to Print Multiplication Table
- C Program Array with Example
- Binary Search in C Program Using Recursion
- Bubble Sort in C Using Pointers
- Bubble Sort Program in C Using Recursion
- Bubble Sort Program in C Using Array
- Bubble Sort Program in C Using Function
- Bubble Sort Program in C Using Linked List