Page 23 - Touchcode_C7_Flipbook
P. 23

Then, assign the value of temp to ‘num2’. Finally, Print the values of ‘num1’ and ‘num2’ which
                 are now swapped. If you follow the steps correctly in sequence, you will achieve the output.

                 This is how sequencing in programming works.
                                                                                                      Subject Enrichment

                   Example 2: Pseudocode to check if the citizen is a senior citizen or not on the basis of
                   age entered by the user. (A person is considered a senior citizen if his/her age is above
                   60 years old.) (Selection)

                   Program Start

                   int age=61;
                   if (age>=60)
                       print(“Person is a senior citizen”);
                       else

                   print(“Person is not a senior citizen”);
                   Program End


                 Explanation: In this, the pseudocode will check if the person is a senior citizen or not on the
                 basis of age entered by the user. You will see that the program makes a ‘selection’ depending
                 on the age entered by the user. If the age is more than or equal to 60, the program enters the
                 if block. If the age is less than 60, the program enters else block.
                                                                                                     Subject Enrichment

                   Example 3: Flowchart to print all the natural numbers from 1 to 100. (Iteration)

                                                           Start


                                                  Start a loop from 1 to 100





                                                      Is the number a   Yes   Print the number
                                                     Natural Number?


                                                              No

                                              Move to next number in the loop



                                                        Did the loop     No
                                                        reach 100?


                                                              Yes
                                                            Stop



                                                                                 Sequencing with Block Coding    21
   18   19   20   21   22   23   24   25   26   27   28