Bubble Sort Descending Order Java

 Bubble Sort  Descending Order Java

Bubble Sort Descending Order Java

In this tutorial  I am going to show how to do   Bubble Sort In Descending Order Java

I am uploading these types of program. However, if you need fully compiled solution of any type of Java program then simply leave a comment below, I will help you at the earliest. 😊😊

 import java.util.*;  
 class Bubble_Sort_Descending_Order  
 {  
   public static void main()  
   {  
     Scanner sc=new Scanner(System.in);  
     System.out.println("Enter the size of the array:-");  
     int n=sc.nextInt();  
     System.out.println("Enter the elements of array:-");  
     int b[]=new int[n];  
     for (int i=0;i<n; i++)  
       b[i]=sc.nextInt();  
     int temp;  
     for(int j=0;j<n-1;j++)  
     {  
       for(int k=0;k<n-1;k++)  
       {  
         if(b[k]<b[k+1])  
         {  
           temp=b[k];  
           b[k]=b[k+1];  
           b[k+1]=temp;  
         }  
       }  
     }  
     System.out.println("Elements After Sorting:-");  
     for(int j=0;j<n;j++)  
       System.out.println(b[j]+" ");  
   }  
 }  
 -------------  
 OUTPUT:-  
 -------------  
 Enter the size of the array:-  
 5  
 Enter the elements of array:-  
 1  
 2  
 3  
 6  
 5  
 Elements After Sorting:-  
 6  
 5  
 3  
 2  
 1  
 ---------------------------  
Checkout:-  Prime Adam Number – ISC 2020 Computer Practical Question 1
 

Post a Comment

0 Comments