Syvum Home Page

Home > Discussions > For all activities

Discussion topic: Contributed Answer/Explanation to Q. 12

Viewing replies        View entire discussion

To go to the homepage of this topic, click here.
Home: jishaOriginal MessageReply  
Subject: Contributed Answer/Explanation to Q. 30
   :-
   import java.io.*;
   class Bubble25
   {
   public static void main(String args[])throws IOException
   {
   DataInputStream in=new DataInputStream(System.in);
   int i,j,tmp;
   int a[]=new int [5];
   System.out.println("Enter the elements");
   for(i=0;i<5;i++)
   {
   a[i]=Integer.parseInt(in.readLine());
       }
       for(i=0;i<5;i++)
      
       for(j=i+1;j<5;j++)
       {
	   if (a[j]<a[i])
	   {
	       tmp=a[i];
	       a[i]=a[j];
	       a[j]=tmp;
	   }
       }
       System.out.println("Array in order is");
       for(j=0;j<5;j++)
       {
	   System.out.println(a[j]);
       }
   }
       }

Posted at: Thu Feb 18 15:04:04 2010 (GMT)

Page 1 of 1
From: jishaReply 1 of 1Reply
Subject: Contributed Answer/Explanation to Q. 30
   :-
   import java.io.*;
   class Bubble25
   {
   public static void main(String args[])throws IOException
   {
   DataInputStream in=new DataInputStream(System.in);
   int i,j,tmp;
   int a[]=new int [5];
   System.out.println("Enter the elements");
   for(i=0;i<5;i++)
   {
   a[i]=Integer.parseInt(in.readLine());
       }
       for(i=0;i<5;i++)
      
       for(j=i+1;j<5;j++)
       {
	   if (a[j]<a[i])
	   {
	       tmp=a[i];
	       a[i]=a[j];
	       a[j]=tmp;
	   }
       }
       System.out.println("Array in order is");
       for(j=0;j<5;j++)
       {
	   System.out.println(a[j]);
       }
   }
       }

Posted at: Thu Feb 18 15:05:47 2010 (GMT)

Page 1 of 1

To post to this forum, you must be signed in as a Syvum member. Please sign in / register as a member.

Contact Info © 1999-2024 Syvum Technologies Inc. Privacy Policy Disclaimer and Copyright