Sunday, August 12, 2012

Java program to find largest element of an programmer defined array


class largest
{
int a[]={12,10,8,9,44,23,44,66,84,1};
int large;
void findlarge()
{
large=a[0];
for(int i=0;i<10;i++)
    {
if(large<a[i])
{
large=a[i];
}
   }
System.out.println("Largest is "+large);
}

public static void main(String s[])
{
largest l=new largest();

l.findlarge();
}
}

0 comments:

Post a Comment