Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 108 - 2609_Logicode
P. 108

    JUMP STATEMENTS

                      Jump statements in programming are used to change the flow of control by skipping, starting
                      again or exiting certain parts of the code. We can use break and continue statements for the
                      same. These statements are known as jump statements.

                      BREAK
                      The break statement changes the normal flow of execution of the statement by exiting the existing
                      loop and continuing the flow of statement after that loop. Using break statement, the control
                      skips the lines after the break statement if present and executes the first statement outside the
                      loop. Break statement is used to come out of a loop early when the specific condition is met. For
                      example: if you’re going through items and find what you’re looking for, you can use break to exit
                      the loop early.
                      Let us create a project in MakeCode Arcade that demonstrates the use of break block. Prepare
                      the project in MakeCode Arcade to display the numbers till 6 but as soon as it reaches 4 it exits
                      from the loop as shown below:

                      106   Premium Edition-VIII

| 103 104 105 106 107 108 109 110 111 112 113 |