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. it is possible try it

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

  4. Anonymous says:

    ty mate 🙂

  5. Anonymous says:

    if i sort array with this code its ascending for me

  6. Anonymous says:

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

  7. nepp says:

    tnx for this example , it helps me a lot

  8. Anonymous says:

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

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

  10. Anonymous says:

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

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

  12. 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

  13. asha gupta says:

    thank it’s very helpful

  14. 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 *

FREE C Programming Cheatsheet

FREE C Programming Cheatsheet

 

Cheatsheet for a quick glance at C programming concepts and syntax

Thank you! Check you inbox and access your cheat-sheet