Sort array in descending order

Write a program in C language which accepts integer values from user, sorts it in descending order and prints the integers in descending order.

#include
#include
void main()
{
    int arr[100],i,j,no,temp;
    clrscr();
    printf("\nEnter the no of Elements: ");
    scanf("%d", &no);
    
    for(i=0;i

Output:

Enter the no of Elements: 5

Enter Element 1: 1

Enter Element 2: 2

Enter Element 3: 3

Enter Element 4: 4

Enter Element 5: 5

Sorted array:   5       4       3       2       1

You may also like...

16 Responses

  1. Anonymous says:

    excellent explanation………

  2. awesome…nothing is easier code than this one…thanks a lot…!!!

  3. Anonymous says:

    ty mate 🙂

  4. Anonymous says:

    if i sort array with this code its ascending for me

  5. Anonymous says:

    you need to change from this for(j=i;j for(j=i;j<=no;j++

  6. nepp says:

    tnx for this example , it helps me a lot

  7. Anonymous says:

    Nice explanation it was vry useful thank u so mch……

  8. thanks for solving my doubt I am now clarified thanks to
    LEARN C ONLINE…….

  9. Anonymous says:

    Great Job!!
    Keep it up..
    It helps me..

  10. You never used integer ‘element’ ,what’s the point of putting it ?

  11. LearnCOnline says:

    Hello,
    Thanks for correcting us. We have removed the int variabled named “element”.

    Thanks,
    LearnCOnline Team

    http://www.learnconline.com
    For C++ online tutorial:
    visit: http://www.learncpponline.com

  12. asha gupta says:

    thank it’s very helpful

  13. danish says:

    i want a turbo c program for sorting of character array,,,,,

  1. March 1, 2014

    […] Sort array in descending order […]

Leave a Reply

Your email address will not be published. Required fields are marked *