Page 75 - Touchcode_C8_Flipbook
P. 75

Let’s take the example of Iteration:
                                                                                                     Subject Enrichment
                  Example 3: Flowchart to print all the natural numbers from 1 to 100.



                                                            Start



                                                           n = 100
                                                            i = 1





                                                  Yes                   No
                                                           i > n?





                                                                        print i


                                                                        i = i + 1



                                                             Stop


                 Explanation: To print all the natural numbers from 1 to 100, the flow of the program
                 will repeat or iterate for each number from 1 to 100. For every single iteration it will
                 check for the condition and take the appropriate path. This is how iteration works in

                 programming. It will repeat the block of code for multiple times until the specified
                 condition is achieved.

                                          Coding fact


                   Donald  Ervin  Knuth  is  an  American computer  scientist,  mathematician,  and
                   professor emeritus at Stanford University. He is called the “father of the
                   analysis of algorithms”.





                                                                                                     Subject Enrichment


                  Example 4: Flowchart to print all the numbers divisible by 3 between 0 and 100.







                                                                                        Advanced Sequencing      73
   70   71   72   73   74   75   76   77   78   79   80