51. JAVA Program To find the Biggest number from the given numbers.
How does this program work?
- This code helps to find biggest among the give numbers.
- Here we find biggest of a number among the given 5numbers.
- Here we took 5variables to store 5numbers.
- By using the simple if case we compare the numbers easily.
Here is the code
//Biggest Number.
import java.util.Scanner;public class large
{
public static void main(String args[])
{
int i,n,large;
System.out.println("Enter the number of elements:") ;
Scanner obj = new Scanner(System.in );
n = obj.nextInt();
int[] a = new int[n];
System.out.println("Enter the elements") ;
for ( i=0;i< n;i++ )
{
a[i] = obj.nextInt();
}
large = a [ 0 ];
for(i=1;i< n;i++)
{
if(large< a[i])
{
large = a[i];
}
}
System.out.println("Largest of "+n+" elements are = "+large);
}
}