adplus-dvertising
frame-decoration

Question

Consider the following iterative code snippet to find the largest element:
Which of the following lines should be inserted to complete the below code?
int get_max_element(int *arr,int n)
{
      int i, max_element = arr[0];
      for(i = 1; i < n; i++)
          if(________)
          max_element = arr[i];
      return max_element;
}

a.

arr[i] > max_element

b.

arr[i] < max_element

c.

arr[i] == max_element

d.

none of the mentioned

Answer: (a).arr[i] > max_element

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Consider the following iterative code snippet to find the largest element: Which of the following lines should be inserted to complete the below code?