Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 81 - 2617_JSSPS_C-6
P. 81

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

                                   Algorithm:                                        Flowchart:

                     Step 1:  Start.                                                   Start
                     Step 2:  Read the number n.
                                                                                      Read n
                     Step 3:  Let i=1, fact=1

                     Step 4:   Check If i < = n Then Repeat                        i = 1, fact = 1
                              Step 5 and 6 until i=n

                     Step 5:  fact=fact*i                                                Is
                                                                                       i < =     No
                     Step 6:  i=i+1                                                     n?

                     Step 7:  Print fact                                                   Yes

                     Step 8:  Stop.                                                fact = fact*i
                                                                                                               Print fact
                                                                                      i = i + 1

                                                                                                                Stop

                              Interdisciplinary Learning                                                        Activity

                        Write an algorithm to calculate the area of a triangle.

                     MIND MAPS

                     A Mind Map is also a problem-solving technique that allows us to organise ideas, thoughts, or concepts
                     and their relationship graphically.
                     In this technique, we pick up the ideas that have common features. These ideas are then grouped
                     under one category, and the different categories are linked to the main topic using lines or arrows.

                                                                                              Algorithmic Intelligence  79

| 76 77 78 79 80 81 82 83 84 85 86 |