Answer

The loop will terminate normally only when the loop variable I becomes larger than SIZE. So, if we check and I is greater than SIZE, we know that the loop terminated normally and that the number N was not found. Otherwise, we know that the loop terminated early, which means that the number was found. (In fact, we even know where in the array it was found.)

Return to lesson.



Hamlet Project
hamlet@cs.utah.edu