For Loop

A for loop is a repetition control structure that allows you to efficiently write a loop that needs to be executed a specific number of times. This is useful when you know how many times a task is to be repeated.

In BeatBlip, FOR command is used to start FOR loop and ENDFOR is used to mark the end of FOR loop. All the steps inside FOR and ENDFOR is the block of steps which will be used in the FOR loop iteration.

Syntax:

For(startindex=0,endindex=5,incrementby=1) where, startindex: This indicates the starting condition of the loop. endindex: This indicates the end condition of the loop. incrementby: Thus indicates the increment count of the loop.

Commands that can be used inside FOR loop:

CONTINUE Command: The continue keyword can be used in any of the loop control structures. It causes the loop to immediately jump to the next iteration of the loop. In a for loop, the continue keyword causes control to immediately jump to the next iteration of the conditional statement.

Syntax:

Example:

BREAK Command: Break command is used to terminate the loop. When the break statement is encountered inside a loop, the loop is immediately terminated and the program control resumes at the next statement following the loop.

Syntax:

Example:

Was this page helpful?