Thursday, 28 July 2011

A simple program to arrange the 10 nos. in ascending order using array.


class ASC
{
Public static void main (String arg[])
{
int I,j,k;
int a[] ={10,12,18,16,3};
for (i=1;i<5;i++)
{
for(j=0;j<=3;j++)
{
if(a[j] > = a [ j+ 1])
{
k=a [j];
a[j]=a[j+1]
a[j+1]=k;
}
}
}
for(i=0;i<5;i++)
{
System.out.println (a [i]);
}
}
}

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More