Bubble Sort Ascending Order Java Program

Bubble Sort Ascending Order Java Program 

Bubble Sort Ascending Order Java Program

Here is  the Java Program Bubble Sort Ascending Order 

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

 import java.util.*;  
 class Bubble_Sort_Ascending_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:-  
 5  
 2  
 4  
 1  
 6  
 Elements After Sorting:-  
 1  
 2  
 4  
 5  
 6  
 -----------------------  

Checkout:- Sum of Left Diagonal Elements of Matrix Java

Checkout:-  Mirror Image of Matrix ISC 2013 Practical Java

Post a Comment

0 Comments