Page 85 - Digicode_AI_class_6
P. 85

Advantages of Pseudocode
                It is language-independent and can be used by most programmers to express the design in plain
               and natural language.
               Programmers do not have to think about syntax, they simply have to concentrate on logic.

               The focus is on the steps to solve a problem rather than how to use the computer language.

            Example 1: Write pseudocode to calculate profit and loss.
                                                                                       Interdisciplinary Learning
            Solution:
            Program Start

            Read Cost price (C.P.)
            Read Selling price (S.P.)
            If (SP>CP) then
              Profit = S.P.-C.P.
              Print Profit

            Else
              Loss= C.P.-S.P.
              Print Loss
            Program End
            Example 2: Write pseudocode to print 'Above average marks' if
                                                                                      Critical Thinking
            the average marks in the three subjects are greater than 60 and
            'Below average marks' if the average marks are less than or equal
            to 60.

            Solution:
            Program Start
            Read marks for subject Num1 (a)

            Read marks for subject Num2 (b)
            Read marks for subject Num3 (c)
            Calculate Sum (S) = a+b+c
            Calculate AverageMarks (A) = S/3

            If (AverageMarks > 60)
            Print (‘Above Average marks’)
            Else

            Print (‘Below Average marks’)
            Program End





                      American computer scientist 'Margaret Hamilton,' wrote the
                      computer code which helped to save the Apollo moon landing
                      mission.


                                                                               Using MakeCode Arcade      83
   80   81   82   83   84   85   86   87   88   89   90