Page 42 - IT_V5.0_Class6
P. 42

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.
                  Step 3:  Let i=1, fact=1                                     Read n
                  Step 4:   Check If i < = n Then Repeat
                             Step 5 and 6 until i=n                         i = 1, fact = 1

                  Step 5:  fact=fact*i
                  Step 6:  i=i+1                                                  Is
                  Step 7:  Print fact                                           i < =     No
                                                                                 n?
                  Step 8:  Stop.
                                                                                    Yes
                                                                             fact = fact*i
                                                                                                        Print fact

                                                                               i = i + 1



                                                                                Stop






                        A problem in computing refers to a task or situation that requires a solution through
                       logical steps and processing.
                        To solve problems effectively, programmers use structured methods such as pseudocode,
                       algorithms, and flowcharts.
                        Pseudocode is a simplified, human-readable version of a programming logic written in
                       plain language without strict syntax.
                        An algorithm is a step-by-step set of instructions to solve a problem or complete a task.
                        Using an algorithm can help make tasks easier and more organised.
                        There are three main control structures: sequential, selection, and repetition.
                        A flowchart is a type of graphical diagram that represents an algorithm.





                      Tech Trivia                                                                Section A (Objective)


                  A.  Tick ( ) the correct option.

                      1.  In an algorithm, what does the term “repetition” mean?

                         a. Skipping a step                             b. Repeating a set of steps
                         c. Ending a process                            d. Starting a process





                    40    Information Technology (V5.0)-VI
   37   38   39   40   41   42   43   44   45   46   47