C Program sorts array arrange in an descending order . Bottom is the source code of the C program how to  to sort the array in an descending order.

Top have image how it will show The C program is successfully compiled and run on a Linux system and code block ide. The program output is also shown like top image.

C Program Descending Order Array


#include <stdio.h>
int main()
{ int s[5],i,j,x;
for (i=0; i<5; i++){ //for loop start
printf(" Enter the value %d: ", i);
scanf("%d", &s[i]); }
j = i-1;
i = 0;
while(i<j){ x = s[i]; // while loop start
s[i] = s[j]; // value swiping
s[j] = x;
i++; j--;
printf(" Descending :");
for (i = 0; i <5; i++) //For loop start
printf(" %d ", s[i]); //Array index valu printing
return (0);


Descending array

Descending array

Leave a reply