c program to arrange numbers in descending order
/* 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
}
}
Also in C:
- epita
- prime check in c
- arduino keypad wait for key
- cannot reach esp8266 via udp while he is running with a static ip
- #include<stdlib.h>
- flip exis in dataframe
- vs code turn off formatter
- resto de division recursiva
- reverse function in c
- RuntimeError: You must setup() the GPIO channel first
- fscanf stops at space
- c programming print pattern pyramid
- 1 212 32123 4321234 543212345 in c
- strtoul C
- amazon kinesis disaster recovery
- change no_turbo
- how to make a linked list in c
- how to pass an array to a thread in c?
- c program to find number of days in a month using switch case
- binary to hexadecimal in c
- plt hide axis ticks
- how to add to the end of a linked list
- get the latest field in mongodb collection
- hello world program in c