import java.util.Scanner;
class Main{
public static void main(String args[])
{
int i,d,temp;
int number=8;
int list[]=new int[number];
Scanner input=new Scanner(System.in);
for(i=0;i<number;i++)
{
System.out.println("Enter the numbers");
list[i]=input.nextInt();
}
for(i=0;i<number;i++){
for(d=0;d<number-i-1;d++){
if(list[d]>list[d+1]){
temp=list[d];
list[d]=list[d+1];
list[d+1]=temp;
}
}
}
for(i=0;i<number;i++){
System.out.println("Bubble sorted list are "+list[i]);
}
}
}
OUTPUT:-
C:\Users\saty\Desktop>javac 1.java
C:\Users\saty\Desktop>java Main
Enter the numbers
24
Enter the numbers
5
Enter the numbers
86
Enter the numbers
12
Enter the numbers
34
Enter the numbers
56
Enter the numbers
4
Enter the numbers
28
Bubble sorted list are 4
Bubble sorted list are 5
Bubble sorted list are 12
Bubble sorted list are 24
Bubble sorted list are 28
Bubble sorted list are 34
Bubble sorted list are 56
Bubble sorted list are 86
It's awesome
ReplyDeletehelpful for my coding
It's a fantastic code
ReplyDeleteAll I can say about this tutorial is "Woooow"
ReplyDeletebeauty of java ...
ReplyDeleteI guess you're a great teacher by birth! Excellent tutorial
ReplyDeleteVery Useful, Simple and clear..Thanks !!!!
ReplyDeleteReally helpful and simple ...
ReplyDeleteyou are the greatest! WOW
ReplyDeleteI guess you're a great teacher by birth
ReplyDeleteYour a good teacher. it's nice way to teach the lessons for all
ReplyDeletePerfect!
ReplyDeletewow this is complete and compact, thank you sir
ReplyDelete