java program for displaying numbers in ascending order

java program for displaying numbers in increasing order

java program for  increasing order of numbers

java program for displaying maximum 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("Increasing Order:");
 for(i=0;i<5;i++)
   System.out.println(""+value[i]); 
}

}

Output:-


Enter 5 element of array
85
64
91
47
26
Increasing Order:
26
47
64
85
91

Enter 5 element of array
12
54
21
54
26
Increasing Order:
12
21
26
54

54

Leave reply

Add your comments here

Back to Top