Consider the following incomplete method. Method findNext is intended to return the index of the first occurrence of the value val beyond the position start in array arr.
// returns index of first occurrence of val in arr
// after position start;
// returns arr.length if val is not found
public int findNext(int[] arr, int val, int start)
{
int pos = start + 1;
while ( /* condition */ )
pos++;
return pos;
}
For example, consider the following code segment.
int[] arr = {11, 22, 100, 33, 100, 11, 44, 100};
Console.WriteLine(findNext(arr, 100, 2));
The execution of the code segment should result in the value 4 being printed.
Which of the following expressions could be used to replace /* condition */ so that findNext will work as intended?
A) (pos < arr.Length) && (arr[pos] != val)
B) (arr[pos] != val) && (pos < arr.Length)
C) (pos < arr.Length) || (arr[pos] != val)
D) (arr[pos] == val) && (pos < arr.Length)
E) (pos < arr.Length) || (arr[pos] == val)