Page 72 - Touchcode_C8_Flipbook
P. 72
Example of sequence is an algorithm, which is a detailed step-by-step process that needs to
be followed in order to complete a task or to solve a problem.
Benefits of using Sequences in coding:
Our manner of thinking can be easily replicated in sequence programming.
Sequence of programming reflects logical thinking.
Example 1: Algorithm of your daily routine
You daily routine is a series of actions which you do every day as follows.
Step 1: Wake up Step 7: Get back home
Step 2: Take a shower Step 8: Watch TV
Step 3: Have breakfast Step 9: Do homework
Step 4: Go to school Step 10: Play
Step 5: Attend classes Step 11: Have dinner
Step 6: Have lunch Step 12: Go to sleep
The above routine may vary from person to person but for a specific person this might be
the routine.
An algorithm is a process or set of rules which need to be followed to solve the given
problem.
Subject Enrichment
Example 2: Algorithm to calculate the sum of two numbers.
Step 1: Input first number (Num1)
Step 2: Input second number (Num2)
Step 3: Sum = Num1 + Num2
Step 4: Print Sum
In the above example, if we swap Step 3 and Step 4, i.e. you are instructing computer to
Print Sum first and after that add Num 1 and Num 2; the program will not give the required
result or give an error. This is called a bug.
70 Touchcode-VIII

