Loops Flashcards
describes repeated addition, or subtraction, wherein the same statement is being repeated many times over, and at some point has to stop.
iteration / loops
checks whether the repetition still needs to be executed.
condition
that changes the value of
the variable used in the condition.
expression or statement
iterates through a block of code as long as a specified condition is true. can be executed many times over, as long as the condition in the parentheses evaluates to false
while loop
used if you know exactly the number of times you want to loop through a block of code.
for loop
once executed at the start of the loop. This will be executed once.
Initializer
behaves similarly with how the condition in the while loop behaves.
condition
performs the updates on certain variables that were used in the loop.
iterator
repetition is achieved by doing or executing the statement in the loop first, before checking
the condition.
do-while loop
when another loop exists in
the body of another loop.
nested loops
It terminates the loop immediately, and the control of the program will move to
the next statement after the loop. Also, it may be sometimes used in decision-making statements.
break
If the break statement cuts the execution, the continue statement skips.
It moves to the end of the iteration, and then the test expression is evaluated, and the update statement is evaluated in case of the for loop.
continue
possible to add break and
continue statements in nested loops.
nested loops
used for the outer loop.
break statement
used for the inner loop.
continue statement