Q. Write a java program to sort ten numbers using bubble sort method.
Ans. class Bubble sort
{
Public static void main (string arts [] throws Io Exception
{
Buffered Reader in=new buffered reader (new input stream reader (system. in) ;
Int num [];
Num=new Int [10];
Int I;
String number;
System.out.printIn ("Enter 10 numbers");
For (I=0; i<10; i++)
{
Number=in. Read Line ();
Number [I] = Integer.parseInt (number);
}
System.out.println ("you have entered");
For (I=0; I<10; I++)
{
System.out.print (" " + num[I]+" ");
}
\\ Sorting beings here
For (I=0; I <10; I++)
{
For (J=0; J < 9-I; J++)
{
If (num [J] > num [J+I])
{
Temp= num [J];
Num [J] = num [J+1];
Num [J+1] = temp;
}
}
}
System.out.println ("array after sorting");
For (I=0; I<10; I++) \\ loop
{
System.out.print (" " + num [I] +" " );
} \\ end loop
} \\ end main
} \\end class