C program to print the descending order using if-else

C program to print the descending order using if-else condition for beginners to sort the program in descending order which means the bigger values are the first values in the output

#include<stdio.h>
void main()
{
int i,j,n,a[100],temp;
printf("Enter the elements\n");
scanf("%d",&n) ;
printf("Enter array elements\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]<a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("After descending order\n");
for(i=0;i<n;i++)
{
printf("%d ",a[i]);
}
}

 

Output:

Enter the elements

5

Enter array elements

34 65 1 78 65

After descending order

78 65 65 34 1

What is descending order and how to implement in c programming

Descending order is a numerical arrangement in which the largest number is placed first, followed by the smallest. The numerals 4, 3, 2, 1 are placed in decreasing order, for example. The reverse of ascending order is descending order. It refers to the practice of organizing numbers in ascending order from greatest to smallest. Descending means “down,” hence descending order indicates that the numbers are decreasing. What does ascending and descending orders mean? The ascending order is denoted by the sign, whereas the descending order is denoted by the > symbol.

What is If else condition and how to execute in c programming language

If else is a conditional statement in programming that executes a separate series of statements based on whether an expression is true or false. If a particular condition is true, the if/else statement executes a block of code. Another block of code can be performed if the condition is false.