Java Programs
Write a program to find the largest of numbers
import java.io.*;
class largestNumber
{
public static void main(String args[]) throws IOException
{
int arr[]= new int[10],i,max;
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter 10 numbers");
for(i=0;i<10;i++)
{
arr[i]=Integer.parseInt(br.readLine());
}
max=arr[0];
for(i=0;i<10;i++)
{
if(max < arr[i])
max=arr[i];
}
System.out.println("Largest Number is "+max);
}
}
Write a program to find the largest of numbers
import java.io.*;
class largestNumber
{
public static void main(String args[]) throws IOException
{
int arr[]= new int[10],i,max;
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter 10 numbers");
for(i=0;i<10;i++)
{
arr[i]=Integer.parseInt(br.readLine());
}
max=arr[0];
for(i=0;i<10;i++)
{
if(max < arr[i])
max=arr[i];
}
System.out.println("Largest Number is "+max);
}
}