Solved

Which of the Following Code Segments Is the Correct Solution

Question 3

Multiple Choice

Which of the following code segments is the correct solution for the following problem? Find the first occurrence of the value "Joe" in the array strNames. Save the index of the element containing "Joe" in a variable named intPosition. Discontinue searching the array once the first occurrence of the element "Joe" has been located. Assume any variables you need are already defined.


A) For intCount = 0 To strNames.length-1 If strNames(intCount) = "Joe" Then
IntPosition = intCount
End If
Next
B) blnFound = True intCount = 0
Do While (Not blnFound) And (intCount < = strNames.Length - 1)
If strNames(intCount) = "Joe" Then
BlnFound = False
Positon = intCount
End If
IntCount += 1
Loop
C) blnFound = False intCount = 0
Do While (Not blnFound) And (intCount < strNames.Length)
If strNames(intCount) = "Joe" Then
BlnFound = True
IntPosition = intCount
End If
IntCount += 1
Loop
D) blnFound = False For intCount = 0 to strNames.Length -1 and Not blnFound
If strNames(intCount) = "Joe" Then
BlnFound = True
IntPosition = intCount
End If
Next

Correct Answer:

verifed

Verified

Related Questions