adplus-dvertising
frame-decoration

Question

Consider the following code snippet to find the smallest element in an array:
Which of the following lines should be inserted to complete the below code?
int get_min_element(int *arr, int n)
{
      int i, min_element = arr[0];
      for(i = 1; i < n; i++)
        if(_______)
          min_element = arr[i];
      return min_element;
}

a.

arr[i] > min_element

b.

arr[i] < min_element

c.

arr[i] == min_element

d.

none of the mentioned

Answer: (b).arr[i] < min_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 code snippet to find the smallest element in an array: Which of the following lines should be inserted to complete the below code?