Page 94 - Plus_V2.2_C6_Flipbook
P. 94

Example 2: Write an algorithm and draw a flowchart to check whether a given number is even or odd.

                  Algorithm:                                 Flowchart:
                  Step 1:  Start                                                       Start
                  Step 2:  Read a Number

                  Step 3:  Check If Number mod 2 = 0 Then                            Input Num
                          print "Number is Even"

                          Else
                                                                                        Is
                          print "Number is Odd"
                                                                                  Number mod 2 = 0?
                  Step 4:  Stop

                                                                               True             False


                                                                 Print "Number is Even"       Print "Number is Odd"





                                                                                        Stop



                  Example 3: Write an algorithm and draw a flowchart to check whether a given number is divisible by
                  5 or not.
                  Algorithm:                                 Flowchart:

                  Step 1:  Start                                                      Start
                  Step 2:  Read a Number

                  Step 3:  Check If Number mod 5 = 0 Then                          Input Num
                          print "Number is divisible by 5"
                          Else

                          print "Number is not divisible by 5"                         Is
                                                                                Num mod 5 = 0?
                  Step 4:  Stop



                                                                             True              False


                                                              Print "Number is divisible      Print "Number is not
                                                                      by 5"                      divisible by 5"





                                                                                      Stop







                  92    Premium Edition-VI
   89   90   91   92   93   94   95   96   97   98   99