Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 87 - 2632_CodeMind
P. 87

    Continue

                      The continue statement forces the next iteration of the loop to execute and skips the line of code within the
                      loop. While executing a program, if the program control encounters a continue statement, the execution of
                      the remaining statements inside the loop are skipped for the current iteration and the control jumps to the
                      beginning of the loop for the next iteration. The loop’s condition is checked again and if it is true, then the
                      control enters the loop, otherwise the control will be moved to the statement immediately after the loop.
                      For example, if you want to skip certain values but continue looping, you use continue.
                      Let us create a project in MakeCode Arcade that demonstrate the use of continue block. Prepare the
                      project in MakeCode Arcade to display the numbers 0 to 9 but as soon as it reaches 3 it exits from the
                      loop as shown below:

                      Now, click on the A button in the Game Controls to view the output of last iteration of the for loop. Notice
                      that, when the index value is 3, the loop skip the current iteration and display the output of other iterations
                      of the while loop.

                      86    Premium Edition-VIII

| 82 83 84 85 86 87 88 89 90 91 92 |