Page 68 - Computer Genius Class 07
P. 68

To reach the final output  you need to  ollo  the algorithm step  y step.
                  Explanation: Read the two numbers “num1 and num2” that needs to be swapped. Assign the value
                  of num1 to a temporary variable called “temp” and the value of num2 to num1. Then, assign 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. Skipping any step from this
                  sequence or altering the sequence will lead to errors in the program or generation of wrong output.
                  This is how sequencing in programming works.
                  Let’s take the example of Selection:

                  Example:  seudocode to chec  i  the citi en is senior citi en or not on the  asis o  age entered  y
                  the user.   erson is considered a senior citi en i  his her age is a o e    years old.
                  int age = 61:
                  if (age>=60)

                  print   erson is a senior citi en
                  else
                  print   erson is not a senior citi en

                  Explanation:  n this the pseudocode  ill chec  i  the person is a senior citi en or not on the  asis o
                  age entered by the user.
                  If you follow the sequence of pseudocode, you will see that the program makes a “selection” of
                   hich  o  to enter depending on the age defined in the program.
                  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.

                  Example: Flowchart to print all the natural numbers from 1 to 100.
                                                                  Start


                                                                 Input N




                                                              FOR 1<num*2





                                                                   IF

                                                                1%2 !=0



                                                              SUM = SUM+1



                                                                Print SUM


                                                                  Stop


                      66     Computer Genius-VII
   63   64   65   66   67   68   69   70   71   72   73