Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 114 - logicode 2609 C6
P. 114

    Example 1: Write pseudocode to calculate profit and loss.

                      Solution:
                      Read CostPrice

                      Read SellingPrice

                      IF (SellingPrice  >CostPrice ) THEN
                        Profit = SellingPrice - CostPrice

                        PRINT Profit

                      ELSE
                        Loss= CostPrice - SellingPrice

                        PRINT Loss
                      Example 2: Write pseudocode to print 'Above average marks' if 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:

                      Read Eng_Marks

                      Read Math_Marks

                      Read Sci_Marks
                      Sum=  Eng_Marks+Math_Marks+Sci_Marks

                      Avg_Marks = Sum / 3

                      IF (Avg_Marks > 60) THEN
                        PRINT "Above Average marks"

                      ELSE
                        PRINT "Below Average marks"

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

                                MAKECODE ARCADE

                      MakeCode Arcade is a free, open-source, online integrated development environment (IDE) for
                      game production. Drag-and-drop block programming is used in this user-friendly coding editor
                      for beginners.

                       112  Premium Edition-VI

| 109 110 111 112 113 114 115 116 117 118 119 |