Contact Learn C
Copy Program Share Program

Program 111:Sort array in Descending order

Program 111:
#include<stdio.h>
main()
{
int i,j,num,temp;
printf("Enter number of elements\n");
scanf("%d",&num);
int a[num];
printf("Enter numbers\n");
for(i=0;i<num;i++)
{
 scanf("%d",&a[i]);
}

for(i=0;i<num;i++)
{
 for(j=i+1;j<num;j++)
 {
  if(a[i]<a[j])
  {
   temp=a[i];
   a[i]=a[j];
   a[j]=temp;
  }
 }
}

printf("Descending order of given numbers is\n");

for(i=0;i<num;i++)
{
 printf("%d\n",a[i]);
}

}

Explanation:

//Coming Soon...

 Output:

Sort array in Descending order





Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide