top of page
For Loops
For loops follow the syntax: for(initialize; condition; increment){ execute }
With for loops we can simplify some functions we would normally have to put in the body of a while loop. Two things we can do with for loops that we cannot do in the condition statement of a while loop includes initializing variables and doing programmatic incrementation. While the condition is met, the loop will continue to loop. The loop will not leave until it either no longer meets the condition or is told to break manually.
Example:
Output:


bottom of page