AP Computer Science Principles Quiz
16 questions · no time limit
0:00
ALGORITHMS AND PROGRAMMING
Question 1 of 16
No time limit
Current
Answered
Flagged
Not seen
A student wants to find where a target word appears in a vocabulary list. Examine the following code snippet, which uses iteration to search the list one item at a time and returns the index when a match is found. target <- "loop" foundIndex <- -1 // -1 means not found index <- 0 WHILE index < LENGTH(words) AND foundIndex = -1 IF words[index] = target foundIndex <- index // record match END IF index <- index + 1 // move to next item END WHILE DISPLAY(foundIndex) This WHILE loop continues as long as the index is in range and the target has not been found; it checks one element per iteration and terminates when either condition fails. If words is ["for", "while", "loop", "if"], the purpose is to locate the first occurrence of target. Examine the following code snippet: What condition causes the loop to terminate?
YOUR PROGRESS
16
QUESTIONS
Ready when you are
Answer in any order. Your progress shows here as you go.
QUESTIONS
KEYBOARD
Pick an answer ABCD
Next question ↵→
Previous ←
Flag for review F