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 : Modeling Language for SPIN-Promela

    Modeling Language: The modeling language used for SPIN is called Promela (Process Meta Language). In fact, the name SPIN stands for Simple Promela Interpreter. Promela is a powerful C-like specification language with a variety of synchronization primi

  • Q : Embedding C Code-Promela Embedding C

    Embedding C Code: Promela supports the use of embedded C code fragments inside the models through the use of the c_code primitive. 12_c</span></p>
                                        <!-- /comment-box -->
                                        <div class=

    Q : Who developed Extensible Hyper-Text

    Who developed Extensible Hyper-Text Markup Language? Answer: XHTML (Extensible Hyper-Text Markup Language) was developed by W3C HTML Working Group along with Steven

  • Q : State term System call executable

    State the term System call executable binary file in a process.

  • Q : Source and listener What do you mean by

    What do you mean by the term source and listener?

  • Q : What is a Real-Time System What is a

    What is a Real-Time System?

  • Q : What is an Interrupt Interrupt : This

    Interrupt: This is an asynchronous message sent to a process or thread which interrupts what it is at present doing. This generally outcomes in an InterruptedException object being received by an interrupted thread. Waiting for an int

  • Q : Limit the Use of Pre-processor

    Limit the Use of Pre-processor Directives: The C pre-processor is powerful, but unrestricted use of it can lead to code that is hard to understand and analyze. Limit its use to inclusion of header files and simple macro definitions. Avoid features suc

  • Q : Explain Multiple inheritance Multiple

    Multiple inheritance: The capability of a class or interface to expand more than one interface or class. In Java, multiple inheritance is only accessible in the circumstances which are shown below: An interf

  • Q : Explain String String: It is an

    String: It is an instance of the String class. A string comprises of zero or more Unicode characters, and they are not mutable or immutable, once formed. The literal string is written between a pair of string delimiters ("), as:

    Discover Q & A

    Leading Solution Library
    Avail More Than 1423184 Solved problems, classrooms assignments, textbook's solutions, for quick Downloads
    No hassle, Instant Access
    Start Discovering




    Active Tutors



    Start Excelling in your courses, Ask an Expert and get answers for your homework and assignments!!

    Submit Assignment

    ©TutorsGlobe All rights reserved 2022-2023.