Page 81 - CloudGPT_C8_Flipbook
P. 81

break
                 display Bye!
                 Program End

                 Continue Statement

                 The continue statement forces
                 the next iteration of the loop               While (Loop-Condition)
                 to execute, and skips the line               {  Statement 1;
                 of code within the loop. While                 Statement 2;     When  the  continue  statement
                 executing  a program, if  the                  ...........      comes in between the execution

                 program control  encounters                    Continue;        of the program, it skips the line of
                                                                ...........
                 a  continue  statement, the                  }                  code and jumps to the beginning
                                                                                 of the loop.
                 execution  of  the  remaining                Statement

                 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.


                                                                                                      Subject Enrichment
                   Example 2: To print number from 9 to 2 by using  the continue
                   statement, but does not print when the value is 4.

                 Pseudocode:

                 Program Start
                 set value of b to 9

                 while b is greater than 0
                        decrease the value of b by 1
                        if value of b is equal to 4
                        continue
                        display 'Current variable is: ' value of b

                 display Bye!
                 Program End

                   Coding           uiz   02
                                                                                                       Critical Thinking


                    Give one word answer to the following questions.

                    a.  Which statement skips the remaining statements in a loop?    .................................

                    b.  Which statement terminates the existing loop?                       ..................................



                                                                                     Loops Using Block Coding    79
   76   77   78   79   80   81   82   83   84   85   86