0

How to display no.s in decending order

4,7,45. Output-45,7,4

21st Mar 2018, 6:33 PM
Shubhojit Sen Gupta
Shubhojit Sen Gupta - avatar
2 Respuestas
+ 17
1)take the numbers in an array . 2) sort the array in descending //either by sort method or by making your method 3) and then simply print the elements of the array //in java
21st Mar 2018, 9:06 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 2
you can use an array to store these values and then you can compare and sort them, by swapping. swapping logic : if nos[ i ] < nos[ j ] temp = nos [ i ]; nos [ i ] = nos [ j ]; nos [ j ] = temp; Likewise, you can sort in ascending order too. Although there are many sorting algorithms are there, you can use that too. Hope, it helps😃
21st Mar 2018, 6:57 PM
Nilesh
Nilesh - avatar