Page 103 - Computer Science Class 11 Without Functions
P. 103

Example: Write a pseudocode and draw the flowchart to compute the factorial of a number.

            Input:
                num: the number whose factorial is required


            Process:
                Compute the product of numbers 1 to num.
            Output:
                Product as the factorial of given number
            input num

            product = 1
            for i = 1 to num
                 product = product * i

            end-for
            Print product
            The flowchart of the above pseudocode is as follows (Fig 4.12):


                                             Start




                                           input num



                                           product = 1





                                                                         i = 1




                                                      False
                                                                        i< = num



                                                                             True
                                                                    product = product*i



                                                                         i = i + 1




                                             print product



                                                Stop


                                         Fig 4.12: Flowchart to compute the factorial of a number


                                                                                                Problem Solving  101
   98   99   100   101   102   103   104   105   106   107   108