Normally a loop runs its whole body on every iteration and stops only when its condition fails or its sequence runs out. Two keywords let you change that from inside the body. break ends the loop immediately; execution jumps to the first statement after the loop. continue ends only the current iteration; the rest of the body is skipped and the loop moves on to its next iteration. Neither keyword takes an argument. For a while loop that means re-checking the condition; for a for loop it means taking the next item.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 5 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.