Loop
A programming construct that allows a set of statements to be repeated multiple times as long as a certain condition is true.
While Loop
A type of loop that continues to cycle through as long as a specified condition is true.
Infinite Loop
A loop that continues indefinitely because the condition to exit the loop is never met.
For Loop
A type of loop that allows for more structured looping by specifying an initialization, condition, and incrementation of a variable.
Initializer
The first step in a for loop where a variable is initialized to a certain value.
Condition
The second step in a for loop where a condition is checked to determine if the loop should continue executing.
Statements
The third step in a for loop where a set of statements is executed as long as the condition is true.
Incrementer
The fourth step in a for loop where the value of the variable is incremented or changed.
Code for a for loop
for(/*initializer*/; /*condition*/; /*incrementor*/)
{
/*statements*/
}
//Note that all comments above would be filled with code acting as the specified task.
Code for a while loop
while(/*condition*/)
{
/*statements*/
}
//Note that all comments above would be filled with code acting as the specified task.
Where in a for-loop would code such as "i++” go?
Incrementor
Where in a for-loop would code such as "int i = 0” go?
Initializer
Where in a for-loop would code such as "i < 10” go?
Condition
Where in a while-loop would code such as "i < 10” go?
Condition
Where in a while-loop would code such as "i++” go?
Statements