Page 19 - Touchcode_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 = S.P. – C.P.
Step 5: Elif S.P. < C.P., print Loss = C.P. – S.P.
Step 6: Else (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 marks
Average = Sum of marks/Total number of marks
Condition:
If A> 60, print "Above average marks"
If A ≤ 60, print "Below average 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: Declare 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: Else, print "Below average marks"
Step 8: End
Coding fact
Ada Lovelace created and published the first algorithm for execution on a machine.
Algorithms with Block Coding 17

