Back to Iteration

Lesson PreviewLesson 1 of 5 in this unit

4.1 while Loops

Part of Iteration in AP® Computer Science A. Read the opening section, then create a free account for the full interactive lesson, practice, and progress tracking.

A loop is a way to repeat a set of instructions multiple times. Rather than writing the same code over and over, we can use a loop to execute the same block of code multiple times. This repeated process is known as iteration. Each time the block of code runs, it completes one iteration.

A while loop is a type of loop that continues to execute a block of code as long as a certain condition is true. Before each iteration, it checks whether the condition is met to decide whether to continue or to stop. That condition is a boolean expression, meaning it must be either true or false.

Continue the full lesson in Stellar

Create a free account to unlock the remaining sections, checkpoints, course practice, and progress tracking for AP® Computer Science A.