Page 57 - Touchcode_C3_Flipbook
P. 57

4.4               PROGRAMS : DECISION MAKING










                 Decision  making is a process of making choices by  identifying  an information.
                 Let us understand through the given examples.


                 Mommy has asked me to go to sleep after dinner. Let’s write a program for
                 this.


                 Program


                   if (i had dinner)

                   then

                       go to sleep
                   otherwise

                       have dinner







                 1.   When the ‘If’ condition is ‘Yes’, then                                            Then......
                     we follow ‘then’ statement.                                        Yes

                 2.   When the ‘If’ condition is giving                       IF
                     an answer as ‘No’, then we follow
                     ‘otherwise’ statement.                                             No           Otherwise......




                                                                        Program

                                                                          read a num

                 Similarly, we  can write a program                       if (num is divided into two

                 to check whether a given  num is                         equal half)
                 even or odd.                                             then
                                                                              print it is even
                                                                          otherwise

                                                                              print it is odd



                                                                         Level 4: Algorithmic Intelligence       55
   52   53   54   55   56   57   58   59   60   61   62