Java program to sort ten numbers using bubble sort method

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

{

Int num [];

Num=new Int [10];

Int I;

String number;

System.out.printIn ("Enter 10 numbers");

For (I=0; i<10; i++)

{

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

#### Related Questions in Programming Languages

• ##### Q :Explain Synchronized statement

Synchronized statement: It is a statement in which an object-lock should be obtained for the target object prior to the body of the statement and can be entered. Employed to enclose a critical section in order to save a race hazard.

• ##### Q :Use Finite-State Space Abstractions Use

Use Finite-State Space Abstractions: In order to successfully apply explicit-state model checking, defects must be detectable in a sufficiently small state space. This can be achieved either by means of heuristics that constrain the way the state spac

• ##### Q :Subroutine in the programming Describe

Describe the number of ways that an argument is passed to a subroutine in the programming?

• ##### Q :Edit things in Moodle Normal 0 false

Normal 0 false false

• ##### Q :Explain the reason to not carry on

Explain the reason to not carry on extending HTML.

• ##### Q :Function of STR and LPSTR Explain what

Explain what is the function of STR and LPSTR?

• ##### Q :Define the term Blank final variable

Blank final variable: A final variable which is not initialized as portion of its declaration. This variable should be initialized in either an instance initialization block or every of the constructors for its class before it is employed. A static bl

• ##### Q :State Sub type Sub type: It is a type

Sub type: It is a type with a parent super type. The sub-type or super-type relationship is more common than the sub-class or super-class relationship. A class which implements an interface is a sub type of interface. An interface which expands the ot

• ##### Q :Windows Communication Foundation or WCF

Why did Microsoft develop the Windows Communication Foundation (WCF) technology?

• ##### Q :What is Class Selector in the CSS

Explain what is meant by the Class Selector in the CSS?