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
excellent explanation………
it is possible try it
awesome…nothing is easier code than this one…thanks a lot…!!!
ty mate 🙂
if i sort array with this code its ascending for me
you need to change from this for(j=i;j for(j=i;j<=no;j++
tnx for this example , it helps me a lot
Nice explanation it was vry useful thank u so mch……
thanks for solving my doubt I am now clarified thanks to
LEARN C ONLINE…….
Great Job!!
Keep it up..
It helps me..
You never used integer ‘element’ ,what’s the point of putting it ?
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
thank it’s very helpful
i want a turbo c program for sorting of character array,,,,,
Hello,
Thank you for your question.
Please visit the below link to view the program:
https://www.learnconline.com/2015/05/c-program-to-sort-character-array-string-in-ascending-order.html
Also visit http://www.aptuts.com if you want to learn C/C++ with the help of instructor online.
Thanks,
LearnCOnline Team