Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

largest element in array

import java.util.*;
public class tuf {
 
  public static void main(String args[]) {
 
    int arr1[] =  {2,5,1,3,0};
    System.out.println("The Largest element in the array is: " + sort(arr1));
   
    int arr2[] =  {8,10,5,7,9};
    System.out.println("The Largest element in the array is: " + sort(arr2));
  }
  static int sort(int arr[]) {
    Arrays.sort(arr);
    return arr[arr.length - 1];
  }
}
Source by takeuforward.org #
 
PREVIOUS NEXT
Tagged: #largest #element #array
ADD COMMENT
Topic
Name
3+3 =