print numbers in Descending order

 

printing Numbers in descending order


C Program
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int n,i,j,temp;
    printf("Enter the size of the array:");
    scanf("%d",&n);
    int array[n];
    for(i=0;i<n;i++)
    {
        printf("Enter the elemnt %d ",(i+1));
        scanf("%d",&array[i]);
    }
    for(i=0;i<n;i++)
		{
		 for( j=0;j<n;j++)
           {
             if(array[i]>array[j])
			  {
				 temp = array[i];
				 array[i] = array[j];
				 array[j] = temp;
				}
            }		
		}
    printf("Elements in Descending order is: ");
     for(i=0;i<n;i++)
    {
        printf("%d ",array[i]);
    }
}

0 Comments: