Page 19 - CloudGPT_C6_Flipbook
P. 19
Step 2: Read cost price (C.P.)
Step 3: Read selling price (S.P.)
Step 4: If S.P.> C.P.; print profit as S.P.-C.P.
Step 5: If S.P. < C.P.; print loss as C.P.-S.P.
Step 6: If C.P.=S.P.; print no profit no loss
Step 7: End
Interdisciplinary
Example 2: Write an algorithm 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.
Concept:
Sum = Addition of numbers
Average = Sum of marks/Total number of marks
Solution:
Input = Num 1 (a), Num 2 (b), Num 3 (c)
Output = Display Sum (S), Average (A), Above average marks, Below average marks
Algorithm:
Step 1: Start
Step 2: Read the three numbers 'a', 'b', 'c' from the user.
Step 3: Declared variables Sum (S) and Average (A)
Step 4: S =a+b+c
Step 5: A =S/3
Step 6: If A > 60; print 'Above average marks'
Step 7: If A < 60; print 'Below average marks'
Step 8: If A = 60; print 'Below average marks'
Step 9: End
Coding fact
Ada Lovelace created and published the first algorithm for execution on a machine.
Algorithms with Block Coding 17

