Page 91 - Computer Genius Class 06
P. 91

Explanation:
                  ou ha e enter the  um er 1    hich is not di isi le  y 2  so the control goes to  i  else   loc   and
                 the num er is di isi le  y    so the  i  else   loc   ill e ecute and the output  ill  e  pin   color.

                 Jump Statements

                  hile e ecuting a program sometimes  e need to change the  lo  o  the program. To do so   e need
                 change the  lo  o  control  rom one part o  the program to another. For this  e can use  rea  and
                 continue statements.




                                         While (Loop-Condition)
                                         {
                                             tatement 1
                                             tatement 2
                                            ...........
                                                                 ecution  o   the  program
                                             rea
                                            ...........        s ips    a ter   the     rea
                                                               statement is encountered in
                                         }
                                                               the loop  ody.
                                         Statement



                 Break Statement

                 The  rea  statement alters or change the normal  lo  o  e ecution o  the statement  y terminating the
                 e isting loop and continues the e ecution o  the statement  ollo ing that loop.
                  rea  statement is used to come out o  a loop early  hen the speci ic condition is met.
                  n   rea    the  control  s ips  the  lines  a ter  the   rea   statement  is   ound  and  e ecutes  the   irst
                 statement outside the loop.

                 Example 1:  rogram to print num er  rom   to    and another print statement  hen you encounter
                  rea .
                 Pseudocode:

                 Program Start
                 set  alue o  a to
                 while the value of a is greater that 0

                        display   urrent  aria le is     alue o  a
                        decrease the  alue o  a  y 1
                        i   alue o  a is e ual to
                         rea

                 display  ye
                 Program End





                                                                                    Using MakeCode Arcade     89
   86   87   88   89   90   91   92   93   94   95   96