Java program to find the largest of element in the array

package array_largest;
import java.util.*;

public class Array_largest {

 
    public static void main(String[] args) {
   
        int num,i,max = 0;
        System.out.println(“Enter the size of the array”);
        Scanner sc= new Scanner(System.in);
        num=sc.nextInt();
       System.out.println(“Enter the element in the array one by one”);
       int array[]=new int [100];
       for(i=0;i<num;i++)
       {
           array[i]=sc.nextInt();
       }
       System.out.println(“The entered element in the array is”);
       for(i=0;i<num;i++)
       {
           System.out.println(array[i]);
     
       }
       System.out.println(“The largest value in array is “);
       max=array[0];
       for(i=0;i<num;i++)
       {
         
           if(max<array[i])
           {
           max=array[i];
         
         
           }
       }System.out.println(max);
   
    }
 
 
}

OUT-
Enter the size of the array
5
Enter the element in the array one by one
78
65
12
45
32
The entered element in the array is
78
65
12
45
32
The largest value in array is 
78

Leave a Comment

Your email address will not be published. Required fields are marked *

To Resolve this issue at just 5$ from ServerExpert

https://serverexpert.io/

For Hosting please visit Hostingwebsite.io

You have Successfully Subscribed!

Open chat