Page 45 - iPro_trackGPT_V5_Class8
P. 45

Example 3:  Flowchart  to  add  the  first  100  Example 4:  Flowchart to find the greatest of 3
                              natural numbers                                    numbers


                                          Start                                            Start



                                        Sum = 0                               Read three numbers A,B,C




                                          N = 0

                                                                                 No         Is        Yes
                                       N = N + 1                                          A>B?



                                    Sum = Sum + N                           Is        No         No         Is
                                                                          B>C?                           A>C?


                                            Is
                                                                        Yes                                     Yes
                                       N >= 100?
                             No
                                                                         Print B         Print C         Print A

                                                Yes

                                       Print Sum

                                                                                           Stop

                                           Stop



                    SOLVING PROBLEMS USING ALGORITHM AND FLOWCHART


                 Example 5: Write an algorithm and draw a flowchart to calculate the factorial of a number.

                 Algorithm
                 Step 1:  Start.

                 Step 2:  Read the number n.
                 Step 3:  Initialise i=1, fact=1.
                 Step 4:  Check If i < = n Then Repeat Step 5 & 6 until i=n.
                 Step 5:  fact=fact*i.

                 Step 6:  i=i+1.
                 Step 7:  Print fact.

                 Step 8:  Stop.






                                                                                     Algorithms and Flowcharts   43
   40   41   42   43   44   45   46   47   48   49   50