--%>

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 : Programming with C# QUESTION 1      

    QUESTION 1       The following UML diagram describes an abstract class Customer. This class is to be used as part of a Company's inventory system. The inventory system will contain many different types of customers.  A separate s

  • Q : Describe Timers Timers: While time

    Timers: While time values usually cannot be reduced in the target system, their usage can be encapsulated as an abstraction which can be replaced easily (e.g., by a non-deterministic choice) during model checking.

  • Q : Calculate the summation of 1 to some

    Write two programs to calculate the summation of 1 to some integer n using a function called int summation(int n) a) Using a non recursive solution, with a for(i=1, i<=n; i++) loop and b) using a recursive solution, based on the following conditions summation(n) = summation(n-1

  • Q : Function of windows-dot-h header file

    What is the function of <windows.h> header file ?

  • Q : Explain Cohesion Cohesion : The level

    Cohesion: The level to which a component executes a single well-stated task. A strongly cohesive technique, for example, will execute a single task, like adding an item to a data structure, or sorting several data, while a weakly cohesive technique wi

  • Q : Write a function Write a function that

    Write a function that takes an integer value and returns the number with its digits reversed. For example, given 7631, the function should return 1367.

  • Q : Define the term Assignment statement

    Define the term Assignment statement: It is a statement employing the assignment operator.

  • Q : Define Data type Data type : There are

    Data type: There are 8 primitive data types in Java; five of such symbolize numerical types of changeable range and precision - float, double, int, long and short. The remaining three are employed to symbolizing single-bit values (that is, Boolean), s

  • Q : What is High level programming language

    High level programming language: Languages like Ada, Java, C++, and so on which give programmers with features like control structures, classes, methods, packages, and so forth. Such features are mostly independent of any specific instruction set, and

  • Q : Command to recognize type of file

    Specify the command which is used to recognize the type of file?