Question: The following program segment asks the user for a number. It then tries to find the number in the array Numbers. There are a few
The following program segment asks the user for a number. It then tries to find the number in the array Numbers. There are a few bugs. Which of the following solutions best fixes the bugs?
Declare Index as integer Declare Found as integer Declare SearchNumber as integer Declare Numbers as an array with 5 items in it Set Index = 0 Set Found = 1 Set Numbers = [0, 3, 5, 9, 11] Write "Enter a number to search for: " input SearchNumber while (Found = 1) or (Index < 5) if Numbers[Index] = SearchNumber Found = 0 Index = Index + 1 end if end while
| 1. while (Found = 1) and (Index < 5) if Numbers[Index] = SearchNumber Found = 0 else Index = Index + 1 end if end while |
| 2.while (Found = 1) or (Index < 5) if Numbers[Index] = SearchNumber Found = 0 else Index = Index + 1 end if end while |
| 3.while (Found = 1) or (Index < 5) if Numbers[Index] = SearchNumber Found = 0 end if end while |
| 4.while (Found = 0) and (Index < 5) if Numbers[Index] = SearchNumber Found = 0 else Index = Index + 1 end if end while |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
