A Program which perform sorting of group of integer values using thr bubble sort technique Sort group of - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
A Program which perform

A Program which perform sorting of group of integer values using thr bubble sort technique Sort group of

import java.io.*;
class Sort
{
  public static void main(String[]args)throws IOException
  {
     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
{
   // create an int type array
   System.out.println("how many element");
   int n=Integer.parseInt(br.readLine());
   int arr[]=new int [n];
   //accept integer element into the array
   for(int i=0; i<n;i++)
   {
    System.out.println("Enter int ");
arr[i]=Integer.parseInt(br.readLine());
}
// use bubble to sort technique to short the intergers
int limit =n-1;
boolean flag=false;
int temp;
for(int i=0; i<limit;i++)
{
for(int j=0;j<limit-i;j++)
{
if(arr[j]> arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
flag=true;
  }
}
if (flag==false)break;
else flag=false;
}
// display the sorted arry
System.out.println("the sorted array is :");
for(int i=0; i<n;i++)
System.out.println(arr[i]);
}
}
}

About EasyToCode

I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

0 comments:

Featured post

Political Full Forms List

Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

Powered by Blogger.