1/* C program to arrange numbers in descending order DescOrder.C */
2
3#include <stdio.h>
4
5void main ()
6{
7 //variable declaration
8 int number[30];
9 int i, j, a, n;
10
11 //asking user to enter size of array
12 printf("Enter the value of N\n");
13 scanf("%d", &n); //reading array size
14
15 //asking user to enter array elements
16 printf("Enter the numbers \n");
17 for (i = 0; i < n; ++i)
18 scanf("%d", &number[i]); //reading array elements
19
20 /* Logic for sorting and checking */
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 for (i = 0; i < n; ++i)
37 {
38 printf("%d\n", number[i]); //printing numbers in descending order
39 }
40}