--%>

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

           {

            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

   Related Questions in Programming Languages

  • Q : What is Bit Bit : It is a binary digit

    Bit: It is a binary digit that can take on two possible values: 0 and 1. The bits are basic building block of both data and programs. Computers regularly shift data around in multiples of eight-bit units (that is, bytes for the sake of effectiveness).

  • Q : Define the term Graphical User Interface

    Graphical User Interface: A Graphical User Interface (abbreviated as GUI) is a part of a program which permits user interaction through graphical components, like menus, buttons, text areas, and so forth. Interaction frequently includes the usage of a

  • Q : CORBA In what respects did CORBA seek

    In what respects did CORBA seek to improve on technologies such as SunRPC?

  • Q : What is u-area Explain what is meant by

    Explain what is meant by the term u-area (user area)?

  • Q : What is Super type Super type : It is a

    Super type: It is a type with a child sub type. The sub-type or super-type relationship is more common than the sub-class or super-class relationship. An interface which is implemented by the class is a super type of the class. The interface which is

  • Q : Do I need to know SGML or HTML before

    Do I need to know SGML or HTML before learn XML?

  • Q : Describe Multiple-boot options

    Multiple-boot options: The hardware configurations of several computers are capable to run various operating system and window manager combinations. A few systems permit a user to select which combination they wish to utilize during a specific session

  • Q : State the term XHTML State the term

    State the term XHTML?

  • Q : Define Abstract class Abstract class :

    Abstract class: It is a class with the abstract reserved word in its header. The Abstract classes are differentiated by the fact that you might not directly construct objects from them employing the new operator. The abstract class might have zero (0)

  • Q : Explain Mutator method Mutator method :

    Mutator method: It is a method specifically designed to permit controlled modification of a private attribute of a class. By convention, we name the mutators with a set prefix obeyed by the name of the attribute being transformed. For example, the mut