Answers for "Given an array A[] of size n. The task is to find the largest element in it."

0

Given an array A[] of size n. The task is to find the largest element in it.

int largest(int arr[], int n) {
  int max = arr[0];
  int i= 0;

    // Traverse array elements from second and
    // compare every element with current max
    for(i = 1; i < n; i++){
    if(arr[i] > max) 
    max = arr[i];
}
    return max;
}
Posted by: Guest on August-17-2021

Code answers related to "Given an array A[] of size n. The task is to find the largest element in it."

Browse Popular Code Answers by Language