Page 65 - Computer_Genius_v2.1_C7_flipbook
P. 65

Now, click on the A button in the Game Controls to view the output of further iteration of the while
                 loop. Notice that, when the index value is 4, the loop breaks and stops executing further.

































                 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:


























                                                                                Advanced MakeCode Arcade      63
   60   61   62   63   64   65   66   67   68   69   70