Java program for displaying numbers in descending order

Java program for displaying numbers in decreasing order

Java program for  decreasing order of numbers

Java program in minimum order


Program:-

import java.util.Scanner;

class group{
public static void main(String ang[]){
Scanner data= new Scanner(System.in);
int value[]= new int[5];
int temp,i=0,j=0;
System.out.println("Enter 5 element of array");
//Read array number
for(i=0;i<5;i++)
value[i]=data.nextInt();

//logical of increasing order
temp=value[0];
 for(i=0;i<5;i++)
 {
for(j=i;j<5;j++)
{
if(value[i]<value[j])
{
temp=value[i];
value[i]=value[j];
value[j]=temp;
}
}
 
 }
 // Increasing Order out 
 System.out.println("descending Order:");
 for(i=0;i<5;i++)
   System.out.println(""+value[i]); 
}

}

Output:-

Enter 5 element of array
56
14
75
21
91
descending Order:
91
75
56
21
14


Enter 5 element of array
56
91
47
54
12
descending Order:
91
56
54
47

12

Leave reply

Add your comments here

Back to Top