Entering Elements into Array and Calculating the Largest Number


import  java.util.Scanner;
public class arr {
    public static void main(String[ ] args) {
        Scanner s=new Scanner(System.in);
        int arr[ ]=new int[10];
        int lar = 0;
        for (int i=0;i<10;i++)
        {
            int ii=i+1;
            System.out.print("Enter element "+ii+":");
            arr[i]=s.nextInt();
            if (lar < arr[i])
            {
                lar=arr[i];
            }
        }
        System.out.println("Largest no is:"+lar);
    }
}

Share this article on