Question: The program segment below are codes for bubble sort. How does the program sort the values that are entered by the user? Ascending or Descending?
The program segment below are codes for bubble sort. How does the program sort the values that are entered by the user? Ascending or Descending?
Scanner sc=new Scanner(System.in);
int[]numbers=new int[5];
inti,temp,pass=1;
for(i=0;i System.out.print("Enter value for index["+i+"] here --> "); numbers[i]=sc.nextInt( ); } while(pass for(i=0;i<(numbers.length-pass);i++){ if(numbers[i] temp=numbers[i]; numbers[i]=numbers[i+1]; numbers[i+1]=temp; } } pass++; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
