3. Write a C program that sorts an Array in descending order.
Tue Aug 15 2023 21:03:41 GMT+0000 (Coordinated Universal Time)
Saved by
@Codes
// Online C compiler to run C program online
#include <stdio.h>
#include <stdbool.h>
int main() {
int size;
printf("Enter the size of the array: ");
scanf("%d", &size);
int arrange[size];
bool flag = true;
for(int i = 0; i < size; i++){
printf("\nElement - %d: ", i+1);
scanf("%d", &arrange[i]);
}
for(int i = 0; i < size-1; i++){
if(arrange[i] < arrange[i+1])
flag = false;
}
if(flag == true)
printf("The array is sorted in a decending order");
else
printf("The array is not sorted in a decending order");
return 0;
}
content_copyCOPY
Comments