The procedure below is intended to display the index in a list of unique names (nameList) where
a particular name (targetName) is found. If targetName is not found in nameList,
the code should display 0
.
- PROCEDURE FindName (nameList, targetName)
- {
- index ← 0
- FOR EACH name IN nameList
- {
- index ← index + 1
- IF (name = targetName)
- {
- foundIndex ← index
- }
- ELSE
- {
- foundIndex ← 0
- }
- }
- DISPLAY (foundIndex)
- }
Which of the following procedure calls can be used to demonstrate that the procedure does NOT work as intended?