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.

void main()
    int arr[100],i,j,no,temp;
    printf("\nEnter the no of Elements: ");
    scanf("%d", &no);


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

  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:

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

    LearnCOnline Team
    For C++ online tutorial:

  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 *