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 Signal Handler Signal Handlers:

    Signal Handlers: In some operating systems, signal handlers are executed on a thread stack; they “overlay” the current thread execution (which may be used, for example, in combination with setjmp/longjmp to create user-domain lightweight t

  • Q : CORBA allows high performance

    'CORBA was designed to allow high performance distributed applications to be written’. Discuss. Definitely, ’CORBA was designed to allow high performance distributed applications to be written’ because it provides:

  • Q : What is Reader class Reader class : It

    Reader class: It is sub-class of the Reader abstract, stated in the java.io package. Reader classes translate input from the host-dependent character set encoding into the Unicode.

  • Q : Define Number of Interleavings Number

    Number of Interleavings: Besides the raw number of threads, the state space is affected by the number of potential interleavings of these threads. While there exist automated techniques (partial-order reduction) to reduce these interleavings, most mod

  • Q : Function of TCHAR used in Windows

    Write down a program to show the function of TCHAR used in Windows Programming?

  • Q : Detecting sequence in signal line

    Explain how to detect a sequence of ‘1101’ arriving serially from the signal line?

  • Q : Define the term Icon Icon : It is an

    Icon: It is an image intended to communicate the language-or culturally-independent meaning.

  • Q : Advantages of Object oriented

    Q. What are the advantages of Object Oriented Programming languages? Explain them. Ans. : Object oriented programming language has following advantages-

    Q : State the term VHDL or Verilog State

    State the term VHDL or Verilog? Answer: VHDL is extremely high speep integrated chips hardware descripted language as well as verilog is use to verify logic.

  • Q : Scripting Language Programming

    Hi Assignment Team, Please find attachment of my assignment. Please advise if there is any unclear information Regards, King

©TutorsGlobe All rights reserved 2022-2023.