Q:

Java Program to implement bubble sorting in descending Order

0

Program to implement bubble sorting in descending Order

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.Scanner;
public class demo1 
{
 public static void main(String []args) 
 {
  int number, a, b, temp1;
  Scanner input = new Scanner(System.in);
 
  System.out.println("Enter the number of integers:");
  number = input.nextInt();
  int array[] = new int[number];
  System.out.println("Enter " + number + " integers: ");
 
  for (a = 0; a < number; a++) 
  array[a] = input.nextInt();
 
  for (a = 0; a < ( number - 1 ); a++) 
  {
   for (b = 0; b < number - a - 1; b++) 
   {
    if (array[b] < array[b+1]) 
    {
     temp1 = array[b];
     array[b] = array[b+1];
     array[b+1] = temp1;
    }
   }
 }
 System.out.println("Sorted list of integers:"); 
 for (a = 0; a < number; a++) 
 System.out.println(array[a]);
  } 
} 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now