Here is the Java Program Bubble Sort Ascending Order
Checkout:- Java Program to Find Sum of Each Column of Matrix
Checkout:- Sum of Right Diagonal Elements of a Matrix
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
0 Comments
Just write down your question to get the answer...