Written by the Fiveable Content Team โข Last updated August 2025
Verified for the 2026 exam
Verified for the 2026 examโขWritten by the Fiveable Content Team โข Last updated August 2025
Definition
A for loop is a control flow statement that allows you to repeatedly execute a block of code based on a specified number of iterations. It consists of an initialization, condition, and increment/decrement.
While Loop: A while loop is another type of control flow statement that repeatedly executes a block of code as long as a given condition is true.
Nested Loop: A nested loop is when one loop is placed inside another loop. This allows for more complex iterations and patterns.
Index Variable: An index variable is used in loops to keep track of the current iteration or position within the loop. It can be incremented or decremented to control the flow of execution.