0% found this document useful (0 votes)
3 views51 pages

ICT Level 2 Unit 7 - Algorithm & FlowChart

Unit 7 covers the fundamentals of computational thinking and algorithms, including definitions of algorithms, bugs, debugging, and decomposition. It introduces pseudocode, variables, data types, and arithmetic operations, emphasizing the importance of the IPO model for algorithm design. The unit also addresses error detection, including sequencing and logical errors, and provides exercises for practical understanding.

Uploaded by

Yamin Kyi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views51 pages

ICT Level 2 Unit 7 - Algorithm & FlowChart

Unit 7 covers the fundamentals of computational thinking and algorithms, including definitions of algorithms, bugs, debugging, and decomposition. It introduces pseudocode, variables, data types, and arithmetic operations, emphasizing the importance of the IPO model for algorithm design. The unit also addresses error detection, including sequencing and logical errors, and provides exercises for practical understanding.

Uploaded by

Yamin Kyi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Unit 7: Computational Thinking & Algorithm Basics

Lesson 1 : Introduction to Algorithms & Decomposition


Learning Objectives:

By the end of this lesson, you will be able to:


• Understand what an algorithm is.
• Understand what a ‘bug’ is and the importance of ‘debugging’.
• Understand decomposition (breaking problems down).
• Identify algorithms in everyday life
• Explain the difference between an algorithm and a program.
• Answer an exam-style definition question about algorithms.

What is Algorithm?

An algorithm is a set of step-by-step instructions used to solve a problem or complete a task.

Algorithms are used by humans and computers. A computer follows algorithms exactly as they
are written.

Key Point
• An algorithm must be clear.
• An algorithm must be in the correct order (sequence).

What is a Bug?
An error or mistake in an algorithm is called a ‘Bug’.

What is Debugging?

Debugging is the process of finding and fixing those bugs to make sure the algorithm works
correctly.

What is Decomposition?
Decomposition is the process of breaking a large, complex problem into smaller, more manageable
parts. Before writing an algorithm, we often use decomposition to understand the different parts of a
task.

Example: Making a Pizza

• Complex Problem: Make a pizza.


• Decomposed Steps: 1. Prepare the dough.
2. Make the tomato sauce.
3. Add the cheese and toppings.
4. Bake it in the oven.

ICT Level 2 Page - 1


KMD Education Centre
Real-Life Algorithms
We use algorithms every day, If the sequence (order) of the steps is wrong, the algorithm will fail.

Example 1: Washing Your Hands


1. START
2. Turn on the tap.
3. Wet your hands.
4. Apply soap.
5. Rub hands together thoroughly.
6. Rinse with water.
7. Dry your hands.
8. STOP

Example 2: Daily Life Algorithm – Brushing Your Teeth

Look at the steps below. This is an algorithm for a daily task.

1. START
2. Unscrew the toothpaste lid.
3. Add a pea-sized amount of toothpaste to the brush.
4. Turn on the tap and wet the brush.
5. Brush all teeth thoroughly.
6. Repeat scrubbing until teeth are clean.
7. Rinse your mouth and the brush.
8. Dry your mouth.
9. STOP.

Algorithm vs. Program

Feature Algorithm Program


Definition A plan or set of steps. Written using a programming language.

Written in code (e.g., Python) or Blocks (e.g.,


Language Simple English / Diagrams
Scratch).

For humans to understand the


Purpose For the computer to execute (run).
plan.

Analogy The Recipe Cooking the meal

Exercise 1: Everyday Algorithm


Write a simple algorithm for “Opening your school bag and taking out a book.”

1. START
2. ---------------------------------------------------------------------------------
3. ---------------------------------------------------------------------------------
4. ---------------------------------------------------------------------------------
5. ---------------------------------------------------------------------------------
6. STOP

Page - 2 ICT Level 2


KMD Education Centre
Exercise 2: Algorithm or Not?

Tick (✓) the correct answer.

1. A recipe for cooking rice ☐ Algorithm ☐ Program

2. Python code that prints a name ☐ Algorithm ☐ Program

3. Instructions for washing hands ☐ Algorithm ☐ Program

Challenge: Making a Cup of Tea

Can you put these steps in the correct sequence? Write numbers 1 to 6 next to each step.

• (....) Add milk and sugar.


• (....) Boil the water in a kettle.
• (....) Put a teabag in a cup.
• (....) Pour hot water into the cup.
• (....) Stir the tea with a spoon.
• (....) Remove the teabag.

Exam Practice (1 mark)

Question 1: State what is meant by the term “algorithm”. (1 mark)

Tip: Use the words “step-by-step instructions” in your answer.

Write your answer below:

--------------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------

Question 2: Give one reason for producing an algorithm before writing a program. (1 mark)

--------------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------

Question 3: It is important to debug every algorithm when complete. What does the term 'debug'
mean? (1 mark) Tip: Think about finding and fixing mistakes.

Answer below:----------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------

ICT Level 2 Page - 3


KMD Education Centre

Unit 7: Computational Thinking & Algorithm Basics

Lesson 2 : Pseudocode, Variable & Data Types


Learning Objectives:

By the end of this lesson, you will be able to:


• Explain what pseudocode is and why it is used.
• Use basic pseudocode commands START, STOP, DISPLAY, INPUT, SET and DECLARE.
• Understand the concept of a Variable as a data container.
• Identify and categorize different Data Types (Integer, Real, Text, Boolean).

What is Pseudocode?

Pseudocode is a way of writing out an algorithm using simple English-like statements. It is not a
real programming language, so the computer cannot run it, but it helps programmers plan the
logic before writing real code (like Python).

Basic Rules:

1. Always begin with START and end with STOP or END.


2. Write only one instruction per line.

Common Pseudocode Keywords

Keyword Meaning
START / BEGIN Marks the Beginning of the algorithm.
STOP / END Marks the End of the algorithm
INPUT Get data from the user

OUTPUT / DISPLAY /
Shows a message or the **value of a variable** on the screen
PRINT

SET / ASSIGN Store a value in a variable


DECLARE Creates a new variable and defines its data type.

Comment

• Single-line comments: // ….
• Multi-line/Block comments: /* ….. * /

Example 1: Display sample Message

START
OUTPUT "Hello!"
STOP

What is a Variable?

Page - 4 ICT Level 2


KMD Education Centre
A Variable is a labeled storage space in the computer's memory that holds a piece of information.
Think of it as a "storage box" with a name on it.

• Variable Name: The label used to identify the box (e.g., UserAge).
• Value: The actual data kept inside the box (e.g., 12).

Naming rules for Variables:


• A variable name must start with a letter.
• It can contain letters, numbers and underscores ( _ ), but no other symbols like !, @, #, $ are
allowed.
• No space allowed (Use first_name or FirstName instead).

Data Types

Choosing the correct Data Type is essential for storing data correctly.

Data Type Description Examples

Integer Whole numbers (no decimals). 10, -5, 1000

Real (or Float) Numbers with decimal points. 3.14, 98.6, 0.5

String (Text) A sequence of characters. (Always put in "quotes") "Apple", "Year 6", "123"

Character A single letter, number, or symbol ‘A’, ‘7’, ‘$’

Boolean Can only be one of two values. True, False

Variable Declaration & Assign


1. Declaration: Telling the computer to prepare a box for a specific type of data.

• Format: DECLARE <VariableName> : <DataType>


• Example: DECLARE Age : INTEGER

2. Assign: Putting a value into the box.

Symbols used: <- , = , or := (SET-----TO----)


• Example: SET Age TO 12 , SET Name TO "Mg Mg" , SET city TO "Yangon"

Age <- 12 , Name = "Mg Mg" , city := "Yangon"

Example 2: Displaying a Variable using Assign Symbols

START
DECLARE Name : STRING
Name := "Thomas"
OUTPUT Name
STOP

Exercise 1: Data Type Identification ( Write the correct Data Type next to each value.)

1. 42 : (___________________________)

ICT Level 2 Page - 5


KMD Education Centre

2. "Hello World" : (___________________________)


3. 19.99 : (___________________________)
4. False : (___________________________)
5. ‘M’ : (___________________________)

Exercise 2: Variable in Pseudocode


Identify the Variable Name and the Data Type in the following line: "Set UserAge to 14"

1. Variable Name : (___________________________)


2. Data Type : (___________________________)

Exercise 3: Variable Naming


Tick (✓) the valid variable names:

1. ☐ User Age
2. ☐ User_Age
3. ☐ 1st_Name
4. ☐ Player1

Challenge: Algorithm to Pseudocode


The algorithm below is written in plain English.

1. Start
2. Set the variable Score to 100
3. Display the value of Score
4. Stop
Rewrite this algorithm using pseudocode.

START
______________________________
______________________________
______________________________
STOP

Exam Practice

Question 1: State what is meant by the term "Variable". (1 mark)

Answer: ----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------

Question 2: Complete the table by identifying the most suitable data type. for each item of data. (2
marks)

Data Data Type

Page - 6 ICT Level 2


KMD Education Centre
The first letter of your name

The number of students in a class

Whether a light switch is ON or OFF

The price of a toy (e.g., 9.99)

Question 3: Look at the following pseudocode. It contains an error (bug).

START
DECLARE Score : INTEGER
SET score TO 100
OUTPUT score
STOP

(a) State the name of the process used to find and fix errors in an algorithm. (1 mark)

----------------------------------------------------------------------------------------------------------------

(b) Identify the bug in the pseudocode above. (1 mark)

----------------------------------------------------------------------------------------------------------------

ICT Level 2 Page - 7


KMD Education Centre

Unit 7: Computational Thinking & Algorithm Basics

Lesson 3 : Input, Process & Arithmetic Operators


Learning Objectives:
By the end of this lesson, you will be able to:

• Use the INPUT keyword to get data from users.


• Perform mathematical operations using Arithmetic Operators (+, -, *, /, %).
• Understand the Order of Operations (Precedence).
• Write algorithms using the IPO Model (Input → Process → Output).

Getting Data: The INPUT Keyword

In Lesson 2, we learned how to SET a variable manually. However, most programs need to ask the
user for information. We use the INPUT keyword for this.
Example: Instead of SET Name TO "Mg Mg", we use:
INPUT Name (The computer waits for the user to type their name)

Arithmetic Operators
Computers are excellent at calculation. In Pseudocode and Python, we use specific symbols for
math:

Operator Operation Example Result


+ Addition 10 + 5 15
- Subtraction 10 - 5 5
* Multiplication 10 * 5 50
/ Division 10 / 5 2
Modulo
% 10 % 3 1
(Remainder)

Note: The Modulo (%) operator only gives you the remainder of a division. For example, 10
divided by 3 is 3 with a remainder of 1. So, 10 % 3 = 1.

Order of Operations (Precedence) / BIDMAS rules

When a calculation has many parts, the computer follows a specific order, similar to BIDMAS in
Math. The Letters stand for Brackets, Indices, Division and Multiplication, Addition and
Subtraction. In programming we follow this hierarchy:

B ()
Order of operations

I x2

D ÷
M x
A +
S -

Example: 5 + 2 * 10 The computer does 2 * 10 first (20), then adds 5. Result = 25 (Not 70!)

Page - 8 ICT Level 2


KMD Education Centre
Calculations using BIDMAS

Below are three examples of applying BIDMAS to calculations, using a range of operators.

36 - (10 + 2) * 3 = (6 + 6) / 3 + 8 (14 - 4) =
Brackets first Brackets first
3 * (2 + 4) =
36 – 12 * 3 = 12 / 3 + 8 * 10 =
Brackets first
Then the then the division and
3 * 6 = 18
multiplication multiplication
36 – 36 = 0 4 + 80 = 84

The IPO Model (Input -> Process -> Output)

Every calculation algorithm follows three steps:

IPO Phase Description Pseudocode keyword


Input Getting data from the user INPUT
Process Performing calculations or logic SET / DECLARE
Output Display the result on the screen DISPLAY / OUTPUT / PRINT

Example 1: Calculation using Assign Symbols

START
DECLARE num1, num2, result : INTEGER
num1 := 10
num2 := 20
SET result TO num1 + num2
OUTPUT result
STOP

Example 2: Calculating the Area of a Rectangle

START
DECLARE Length, Width, Area : INTEGER
INPUT Length
INPUT Width
SET Area TO Length * Width
OUTPUT Area
STOP

ICT Level 2 Page - 9


KMD Education Centre
Exercise 1: Finding the Output
Read the pseudocode below and calculate the final output.

Scenario A:

1. START
2. DECLARE Number1, Number2, Result : INTEGER
3. INPUT Number1 (User types 20)
4. INPUT Number2 (User types 5)
5. SET Result to Number1 / Number2
6. OUTPUT Result
7. STOP Final Output: (___________________________)

Scenario B:

1. START
2. DECLARE X, Y, Z : INTEGER
3. SET X to 10
4. SET Y to 2
5. SET Z to (X + Y) * 3
6. OUTPUT Z
7. STOP Final Output: (___________________________)

Exercise 2: Variable Calculation


Complete the two missing sections in the algorithm below.

1. Start
2. ______________________________
3. set distance to 50
4. INPUT speed
5. set time to distance / speed
6. ______________________________
7. Stop

Exercise 3: Writing the Algorithm

Write a pseudocode algorithm that asks the user for their Birth Year, calculates their Age, and
displays it. (Hint: Age = Current Year - Birth Year)

START
______________________________
______________________________
______________________________
______________________________
______________________________
STOP

Page - 10 ICT Level 2


KMD Education Centre

Exam Practice

Question 1: A programmer uses the following instruction: SET Total to 10 + 5 * 2 State the value of
Total. (1 mark)

___________________________________________________
___________________________________________________
___________________________________________________
___________________________________________________

Question 2: An algorithm is needed to calculate the remainder when a number is divided by 2.


Identify the correct operator to find the remainder. (1 mark)

___________________________________________________
___________________________________________________
___________________________________________________

Question 3: Complete the pseudocode to calculate the average of two numbers. (2 marks)

START
DECLARE Num1, Num2, Average: INTEGER
INPUT Num1
INPUT Num2
SET Average TO (_________ + _________) / 2
_________________ Average
STOP

ICT Level 2 Page - 11


KMD Education Centre

Unit 7: Computational Thinking & Algorithm Basics

Lesson 4 : Logic Sequencing & Error Detection


Learning Objectives:
By the end of this lesson, you will be able to:

• Identify and fix Sequencing Errors (Steps in the wrong order).


• Understand and detect Logical Errors (The code runs, but the answer is wrong).
• Use a Trace Table to track variable values and find bugs.
• Master the Debugging process to improve your algorithms.

What is Sequencing? (Why Order Matters)

In programming, the computer follows instructions line by line, from top to bottom. If the steps are
out of order, the algorithm will fail even if the commands are correct.

Bad Example (Making Tea):

1. Pour boiling water into the cup.


2. Drink the tea.
3. Put the tea bag in the cup.
• (This is a sequencing error! You can't drink the tea before putting the tea bag in.)

Understanding Logical Errors

A Logical Error is a bug where the program runs without crashing, but it produces the wrong
result. This usually happens because the math or the logic is incorrect.

Example:

• Goal: Calculate the average of two numbers (10 and 20).


• Wrong Pseudocode: SET Average TO 10 + 20 / 2
• Result: The computer does 20 / 2 = 10, then adds 10. Result is 20 (Wrong!).
• Fix: SET Average TO (10 + 20) / 2 (Result is 15).

Understanding Syntax Errors

Just like English has grammar rules, programming languages have Syntax.

Definition: Syntax is the set of rules that tell us how to write code correctly, including correct
spelling, symbols, and order.

The Rule: Computers are very strict. If the syntax is wrong (for example, wrong spelling or missing
symbols), the program may not run.

The Trace Table (Finding the Bug)

A Trace Table is a tool used to track the value of variables at every step of an algorithm. It helps us
see exactly where the logic goes wrong.

Page - 12 ICT Level 2


KMD Education Centre
Algorithm to Test:

1. START
2. DECLARE X : INTEGER
3. SET X TO 5
4. SET X TO X + 10
5. OUTPUT X
6. STOP

Trace Table

Instruction (Line #) Variable: X Output (Screen)


Line 3: SET X TO 5 5
Line 4: SET X TO X + 10 15
Line 5: OUTPUT X 15 15

Exercise 1: Fix the Sequence


The following algorithm for "Calculating the Area of a Rectangle" is in the wrong order. Rewrite it
correctly below.

1. SET Area TO Width * Height


2. INPUT Width
3. OUTPUT Area
4. INPUT Height
5. START
6. DECLARE Area, Width, Height : INTEGER
7. STOP

Your Corrected Algorithm:

1. START
2. ______________________________
3. ______________________________
4. ______________________________
5. ______________________________
6. ______________________________
7. STOP

Challenge: The Debugger

Look at the pseudocode below. The goal is to calculate the discounted price of a toy.
(Discount = Price - 5).

START
DECLARE Price : REAL
DECLARE FinalPrice : REAL
SET Price TO 20
SET FinalPrice TO Price + 5
OUTPUT finalprice
STOP

ICT Level 2 Page - 13


KMD Education Centre
Find 2 bugs in the code above:
1. Logical Bug: ______________________________
2. Syntax Bug: ______________________________

Exam Practice

Question 1: Which of the following describes a "Logical Error"? (1 mark)

A) The program won't start.


B) The computer follows the steps but gives the wrong answer.
C) The programmer forgot to use the START keyword.

Question 2: Why is a Trace Table useful during debugging? (2 marks)

______________________________________________________________

______________________________________________________________

Page - 14 ICT Level 2


KMD Education Centre

Unit 7: Computational Thinking & Algorithm Basics

Lesson 5 : Flowchart Basic & Symbols


Learning Objectives:
By the end of this lesson, you will be able to:

• Define what a Flowchart is and why it is useful.


• Identify and describe standard Flowchart Symbols.
• Understand the Direction of Flow and basic flowchart rules.

What is Flowchart?

A Flowchart is a diagram that shows the step-by-step logic of an algorithm using different shapes.
While Pseudocode uses English text, a Flowchart uses Visual Symbols. It helps programmers
"see" the logic before writing the actual code.

Standard Flowchart Symbols: Every shape in a flowchart has a specific meaning. You must use
the correct shape for the correct action.

Symbol Name Description


Oval:
Terminal Used at the very beginning (START) and the very end
(STOP) of the flowchart.
Parallelogram:
Input / Output Used when the computer gets data from the user (INPUT) or
shows information (DISPLAY / OUTPUT).
Rectangle:
Process Used for calculations or assigning values
(e.g., SET Total TO A + B).
Arrows:
Flow Line Shows the direction of the algorithm (usually top to bottom or
left to right).

Diamond:
Decision
A diamond indicates a decision

Rules for Drawing Flowcharts:

1. Always start with a START symbol and end with a STOP symbol.
2. Use Flow Lines (arrows) to connect the shapes.
3. Arrows should point in the direction the data is moving.
4. Instructions inside the shapes should be clear and short.

Tip: Common Pitfall

Don't confuse the Process (Rectangle) with the Input/Output (Parallelogram).


• If the computer is "thinking" or "calculating" (e.g., math), use a Rectangle.
• If the computer is "talking" to the user (e.g., asking a question or showing an answer), use
a Parallelogram!

ICT Level 2 Page - 15


KMD Education Centre
Example 1: Simple Greeting Flowchart Algorithm:

Ask for a name and say hello.


START
1. START
2. DECLARE Name : STRING
3. INPUT Name INPUT Name
4. OUTPUT "Hello " + Name
5. STOP

OUTPUT "Hello "+ Name

STOP

(Note: We usually do not draw a separate shape for DECLARE in flowcharts.)

Example 2: Calculating Area of a Square


START

1. START
2. DECLARE Side : INTEGER INPUT Side
3. INPUT Side
4. SET Area TO Side * Side
5. OUTPUT Area
SET Area = Side * Side
6. STOP

OUTPUT Area

STOP

Page - 16 ICT Level 2


KMD Education Centre
Example 3: Making a Cup of Coffee
START

This flowchart shows a simple daily routine.


Put coffee powder
Notice how each step must follow a specific
in a cup
sequence for the algorithm to be successful.

1. START Add boiling


water
2. Put coffee powder in a cup
3. Add boiling water
Add milk and
4. Add milk and sugar sugar
5. Stir the coffee
6. OUTPUT “Enjoy your coffee!”
Stir the coffee
7. STOP

OUTPUT "Enjoy
your coffee"

STOP

Exercise 1: Drawing the Right Symbols

Instead of converting a whole code, let’s practice drawing the symbols for specific actions. In the
box below, draw the correct flowchart symbol for each instruction:

1. Instruction: START
o Your Drawing: (____________________)

2. Instruction: SET Score TO 100


o Your Drawing: (____________________)

3. Instruction: INPUT Name


o Your Drawing: (____________________)

4. Instruction: OUTPUT "Game Over"


o Your Drawing: (____________________)

5. Instruction: STOP
o Your Drawing: (____________________)

ICT Level 2 Page - 17


KMD Education Centre
Exercise 2: Symbol Identification

Label the correct symbol name for each active below:

1. Calculating the area of a square: ____________________________


2. Making the end of the algorithm: ____________________________
3. Asking the user for their password: ____________________________
4. Showing the result of a quiz: ____________________________

Logic Challenge 1: The Age Calculator Error

Scenario: A student wants to create a flowchart that asks for a person's Birth Year, calculates their
Age, and then Displays the result. However, they have made three (3) logic and symbol errors.

The Student's Flowchart:

START

INPUT BirthYear

SET Age TO 2026 - BirthYear

OUTPUT Age

STOP

Task: Find the three errors and explain why they are wrong.

• Error 1: ________________________________________

o Why? ________________________________________

• Error 2: ________________________________________

o Why? ________________________________________

• Error 3: ________________________________________

o Why? ________________________________________

Page - 18 ICT Level 2


KMD Education Centre

Challenge 2: The Symbol Mix-up

A student tried to draw a flowchart to calculate a total score, but they made several mistakes with
the shapes!
Scenario:
• They used a Rectangle to ask for the user’s name: INPUT Name
• They used a Parallelogram for a calculation: Total = Score1 + Score2
• They used Rectangle for the very first step: START

Task: Identify the mistakes and state which symbols SHOULD have been used.

1. Error 1: Using a Rectangle for INPUT Name .


• Correct Symbol: ____________________
2. Error 2: Using a Parallelogram for Total = Score1 + Score2.
• Correct Symbol: ____________________
3. Error 3: Using a Rectangle for START .
• Correct Symbol: ____________________

Logic Challenge 3: The Morning Routine Algorithm

Build Your Morning Routine


Below are 5 steps to get ready for school. Match each step with the Correct Flowchart Symbol.

Step Instruction Correct Symbol


(Oval / Rectangle / Parallelogram)

1 Begin the algorithm

2 Show message: "Don’t forget your bag?"

3 Put on school uniform

4 Show message: "Ready to go!"

5 Finish the algorithm

Exam Practice

Question 1: Which flowchart symbol is used to represent an assignment, such as SET Count TO
0? (1 mark) Tick (✓) the correct answer.

A) ☐ Oval
B) ☐ Rectangle
C) ☐ Parallelogram
D) ☐ Arrow

ICT Level 2 Page - 19


KMD Education Centre
Question 2:
Identify the structural component (symbol) used to represent the start of an algorithm. (1 mark)

Answer: ________________________________________

Question 3:
Give one advantage of using a flowchart rather than pseudocode to show an algorithm. (1 mark)

Answer:________________________________________

Checklist for a Perfect Flowchart:

• ☐ Does it start with an Oval?


• ☐ Are all calculations inside Rectangles?
• ☐ Are all inputs and outputs inside Parallelograms?
• ☐ Do all flow lines (arrows) point in the right direction?
• ☐ Does it end with an Oval

Page - 20 ICT Level 2


KMD Education Centre

Unit 7: Computational Thinking & Algorithm Basics

Lesson 6 : Translation Pseudocode to Flowcharts


Learning Objectives:
By the end of this lesson, you will be able to:

• Map Pseudocode keywords to their correct Flowchart symbols.


• Convert simple algorithms from text (Pseudocode) to visual diagrams (Flowcharts).
• Understand the importance of Sequence in the Input-Process-Output (IPO) model.

Matching Keywords to Symbols

Before we start drawing, let's remember which Pseudocode words belong to which Flowchart
shapes:

Pseudocode Keyword Flowchart Symbol Action

START / STOP Terminal (Oval) Begins and ends the logic.


Input/Output
INPUT / DISPLAY Gets data or shows results.
(Parallelogram)
Does math or changes
SET / CALCULATE Process (Rectangle)
values.

Step-by-Step Translation
To convert Pseudocode to a Flowchart, follow the flow of the code line by line.

Example 1: Interactive Greeting


START
Pseudocode:
START
DECLARE UserName : STRING
OUTPUT "Please enter your name: " OUTPUT "Please enter your name: "
INPUT UserName
OUTPUT "Hello " + UserName
STOP INPUT UserName

Flowchart Steps:

1. START
OUTPUT "Hello "+ UserName
2. OUTPUT "Please enter your name: "
3. INPUT UserName
4. OUTPUT "Hello " + UserName
5. STOP
STOP

(Note: We usually do not draw a separate shape for DECLARE in flowcharts.)

ICT Level 2 Page - 21


KMD Education Centre
Example 2: Simple Addition

Pseudocode: START
START
DECLARE num1, num2, total : INTEGER
OUTPUT "Enter Number1: "
OUTPUT "Enter Number1: "
INPUT num1
OUTPUT "Enter Number2: "
INPUT num2
SET total TO num1 + num2 INPUT num1
OUTPUT "Total Sum=" + total
STOP
OUTPUT "Enter Number2: "
Flowchart Steps:

1. START
2. OUTPUT "Enter Number1: " INPUT num2
3. INPUT num1
4. OUTPUT "Enter Number2: "
5. INPUT num2 SET total TO num1 + num2
6. SET total TO num1 + num2
7. OUTPUT "Total Sum=" + total
8. STOP
OUTPUT "Total Sum=" + total

STOP

Exercise 1: Trace the Flowchart

Look at Example 2 again. If the user provides the following inputs, what will be the Final Output?
• Input num1: 10
• Input num2: 5
Final Output: ____________________

Exercise 2: Drawing Task


Convert the following Pseudocode into a complete Flowchart. (Converts Dollars to Kyats).

Pseudocode:
START
DECLARE Dollars, Rate, Kyats : REAL
OUTPUT "Enter Dollars Amount: "
INPUT Dollars
SET Rate TO 3500
SET Kyats TO Dollars * Rate
OUTPUT Kyats
STOP

Hint for Exercise 2:

Remember, in Flowcharts, setting a value (like SET Rate TO 3500) and calculations (like Dollars *
Rate) are both types of processing. You should put them inside Rectangles (Process symbols)!

Page - 22 ICT Level 2


KMD Education Centre
(Draw your flowchart here)

Challenge 1: The Sequencing Disaster


A student drew a flowchart to calculate the price of a toy after a discount. However, the arrows are
in the wrong order!

The Steps are:


A. OUTPUT FinalPrice
B. INPUT Price
C. START
D. SET FinalPrice TO Price - 5
E. STOP

Task: Rearrange these steps into the correct Logic Sequence so the algorithm works correctly.

1. ______________
2. ______________
3. ______________
4. ______________
5. ______________

Challenge 2: The Logical Sequence

In Lesson 4, we learned that the order of steps is very important. Look at the steps below. If you put
them in a flowchart, which one must come first?

A) SET Result TO A + B
B) INPUT A, B
C) OUTPUT Result

Answer: Step ______ must come first, because the computer needs the numbers before it can
calculate them. This is called the IPO Model (Input-Process-Output).

ICT Level 2 Page - 23


KMD Education Centre

Exam Practice

Question 1: A programmer needs to ask a user for their age. Which symbol and keyword should
they use? Tick (✓) the correct answer. (1 mark)
A) ☐ Rectangle / SET
B) ☐ Parallelogram / INPUT
C) ☐ Oval / START
D) ☐ Diamond / IF

Question 2: Draw a flowchart for an algorithm that asks for a student’s name and their score, then
Displays “Score saved for ” followed by the name. (3 marks)
(Draw your flowchart here)

Question 3: In a flowchart, why must an INPUT symbol come before a PROCESS symbol that uses
that data? (2 marks)

Answer: ________________________________________

Question 4: Draw a flowchart snippet that shows the computer calculating BMI = Weight / (Height *
Height). Assume the inputs have already been taken. (2 marks)
(Draw your flowchart here)

Page - 24 ICT Level 2


KMD Education Centre

Unit 7: Computational Thinking & Algorithm Basics

Lesson 7 : Decision Making Flowcharts (IF / ELSE)


Learning Objectives:

By the end of this lesson, you will be able to:

• Understand how computers make decisions using the Diamond symbol.


• Use Relational Operators (>, <, =, >=) inside a decision.
• Draw flowcharts that split into two paths (YES and NO).
• Create algorithms that react differently based on user input (e.g., Password Check).

The Power of “IF” (Branching)


So far, our flowcharts have been straight lines (Sequence). But real life isn't a straight line!

• Is it raining? → IF YES, take an umbrella. IF NO, wear sunglasses.


• Is the password correct? → IF YES, unlock phone. IF NO, say "Try Again".
In Flowcharts, we call this Selection or Branching.

The Decision Diamond


To ask a question in a flowchart, we use a Diamond Shape.

• The Rule: A Diamond always has ONE entrance but TWO exits.
• The Exits: One exit must be labelled YES (or True) and the other NO (or False).
• The Question: Inside the diamond, we write a condition (e.g., Age > 18?).

Age > 18?

Visualization: Think of the Diamond as a "Fork in the road". The data travels down, hits the
Diamond, answers the question, and then must choose one path. It cannot go both ways!

Relational Operators
Inside the Diamond, we compare things using special math symbols.
Symbol Meaning Example
= or == Is Equal to? 9 = 13
!= or <> Not equal to 9 <> 13
> Is Greater than? 9 > 50
< Is Less than? 9 < 25
>= Greater than OR Equal to 9 >= 18
<= Less than OR Equal to 9 <= 17

Logical Operators
Sometimes, checking one thing is not enough. Imagine a login screen. To enter, you need the
correct Username AND the correct Password. If one is wrong, you cannot enter.
In Pseudocode, we use three main words to combine conditions:
1. AND
2. OR
3. NOT

ICT Level 2 Page - 25


KMD Education Centre
Example 1: The Password Checker
Let’s build a security system. The logic splits based on whether the password is right or wrong.

Pseudocode:
START
START
DECLARE UserPass : STRING
OUTPUT "Enter Password: "
OUTPUT "Enter Password: "
INPUT UserPass
IF UserPass = "Secret" THEN
OUTPUT "Access Granted"
ELSE INPUT UserPass
OUTPUT "Access Denied"
END IF
STOP
" "

Flowchart Steps:

1. START
OUTPUT "Access OUTPUT "Access
2. OUTPUT "Enter Password: " Denied"
Granted"
3. INPUT UserPass
4. Decision: UserPass = "Secret"
* If Yes: OUTPUT "Access Granted"
* If No: OUTPUT "Access Denied"
5. STOP STOP

Example 2: Pass or Fail? (Numeric Logic)


Here is how a computer grades an exam. Note the use of >= (Greater than or Equal).
START
Pseudocode:
START
DECLARE mark : INTEGER
OUTPUT "Enter your mark: " OUTPUT "Enter your mark: "
INPUT mark
IF mark >= 40 THEN
OUTPUT "You Passed!" INPUT mark
ELSE
OUTPUT "Try Again"
ENDIF
STOP

Flowchart Steps:

1. START OUTPUT "You OUTPUT "Try


Again"
2. OUTPUT "Enter your mark: " Passed! "
3. INPUT mark
4. Decision: mark >= 40
* If Yes: OUTPUT "You Passed! "
* If No: OUTPUT "Try Again! "
5. STOP STOP

Page - 26 ICT Level 2


KMD Education Centre
Example 3: Multiple Decision (The Grade Finder)

Sometimes, we need to make more than one choice. This is called a Multiple Selection.

Pseudocode: START

START
DECLARE Mark : INTEGER
OUTPUT “Enter your mark: ” OUTPUT "Enter your mark: "

INPUT Mark
IF Mark >= 80 AND Mark <= 100 THEN
OUTPUT "Grade A" INPUT Mark
ELSEIF Mark >= 40 AND Mark <80 THEN
OUTPUT "Grade B"
ELSE
OUTPUT "Grade C"
ENDIF
STOP

OUTPUT "Grade A"


Flowchart Steps:

1. START
2. OUTPUT "Enter your mark: " OUTPUT "Grade B" OUTPUT "Grade C"
3. INPUT Mark
4. Decision 1: Mark >= 80 AND Mark <= 100?
* If Yes: OUTPUT "Grade A! "
* If No: Move to the next Decision.
5. Decision 2: Mark >= 40 AND Mark < 80? STOP
* If Yes: OUTPUT "Grade B! "
* If No: Move to the next Decision.
6. Process (Else): OUTPUT "Grade C".
7. STOP

ICT Level 2 Page - 27


KMD Education Centre
Example 4: Decision Making with OR Logic
START
Pseudocode:

START
OUTPUT "Enter Day Name: "
DECLARE Day : STRING
OUTPUT "Enter Day Name: "
INPUT Day
IF Day = "Saturday" OR Day = "Sunday" THEN INPUT Day
OUTPUT "It is the Weekend! No School!"
ELSE
OUTPUT "Go to School"
ENDIF
STOP

OUTPUT OUTPUT "Go to


Flowchart Steps: "Weekend!" School"

1. START
2. OUTPUT "Enter Day Name: "
3. INPUT Day
4. Decision: Day = "Saturday" OR Day = "Sunday" STOP
* If Yes: OUTPUT "It is the Weekend! No School!"
* If No: OUTPUT "Go to School"
5. STOP

Exercise 1: Trace the Logic

Look at the "Pass or Fail" Flowchart logic above. Predicting the output for different inputs.

User Input (Score) Condition: Score >= 40? Path Taken (YES / NO) Final Output Message

80 True YES "You Passed!"

30 False ______ _________________

50 True ______ _________________

39 ______ NO _________________

Exercise 2: Drawing Task


Convert the following Pseudocode into a Flowchart.

Pseudocode:

START
DECLARE Temperature : INTEGER

Page - 28 ICT Level 2


KMD Education Centre
OUTPUT "Enter temperature: "
INPUT Temperature
IF Temperature > 30 THEN
OUTPUT "It is Hot"
ELSE
OUTPUT "It is Cool"
ENDIF
STOP

(Draw your flowchart here - Hint: Make sure your Diamond has two clear arrows)

Exercise 3: Complete the Flowchart

Scenario: A "Ticket Machine" at the cinema.

• Rule: If Age is under 12, Ticket Price is $5. Otherwise (Else), Ticket Price is $10.

Fill in the missing logical steps:

Flowchart Steps:

1. START
2. OUTPUT “Enter your age: ”
3. INPUT Age
4. DECISION: is Age <12?
* If Yes: SET Price TO ___________
* If No: SET Price TO ___________
5. OUTPUT "Please pay: " + Price
6. STOP

ICT Level 2 Page - 29


KMD Education Centre

Challenge: The Weather Logic


A student wants to draw a flowchart that asks: "Is it raining?"

• If Yes, it should say "Take an umbrella."


• If No, it should ask another question: "Is it sunny?"
o If Sunny, say "Wear sunglasses."
o If Not Sunny, say "Have a nice day."

Task: How many Decision Diamonds will you need for this flowchart? Answer: ______________

Exam Practice

Question 1: Which flowchart symbol is used to ask a question like "Is X > 10?"? (1 mark)
Tick (✓) the correct answer.

A) ☐ Parallelogram
B) ☐ Rectangle
C) ☐ Diamond
D) ☐ Circle

Question 2: Look at this condition: IF Time >= 12. State whether the result is TRUE (Yes) or
FALSE (No) for the following inputs:

• Time = 9 : __________
• Time = 12 : __________
• Time = 15 : __________

Question 3: Draw a flowchart symbol and arrows for the following logic: "If Battery is less than
20%, Display 'Low Battery'." (2 marks) (Draw a Diamond with a condition inside, and a YES arrow
leading to a Parallelogram)
(Draw your flowchart here)

Page - 30 ICT Level 2


KMD Education Centre
Question 4: Draw a flowchart snippet to check if a number is Even or Odd. Assume the number is
already inputted. (3 marks)
(Draw your flowchart here)

Question 5: Write a pseudo code program to determine vowel or not and accepted one character
from the keyboard. Draw a flowchart.
(Draw your flowchart here)

ICT Level 2 Page - 31


KMD Education Centre

Unit 7: Computational Thinking & Algorithm Basics

Lesson 8 : Introduction to Iteration (Loops / Repetition)


Learning Objectives:

By the end of this lesson, you will be able to:

• Define Iteration and explain why it makes algorithms efficient.


• Identify the two main types of loops: Count-Controlled and Condition-Controlled.
• Draw flowcharts where the arrow points backwards (upstream) to create a loop.
• Understand the danger of Infinite Loops (loops that never stop).

What is Iteration?

Iteration is the process of repeating a sequence of instructions until a specific condition is met. In
computer science, we commonly refer to this as a Loop.

Instead of writing the same code many times, we use a loop to make the algorithm shorter and more
efficient

The Two Types of Loops

Not all loops are the same. We decide when to stop based on two rules:

Type Definition Real-Life Example

1. Count-Controlled We know exactly how many


"Clap your hands 3 times."
(For Loop) times to repeat.

2. Condition-Controlled We repeat until something


"Keep clapping until the
(While Loop / Repeat happens (we don't know how
music stops."
until Loop) many times).

1. FOR Loop
* Used when the number of iterations is known in advance.

FOR variable := start_value TO end_value STEP increment


Statements to be executed
END FOR

2. WHILE Loop
* Test the condition before action.
* Commands may not be executed at all, if condition is false.

Starting State;
WHILE condition
statements to be executed;
increment / decrement;
END WHILE

Page - 32 ICT Level 2


KMD Education Centre
3. REPEAT UNTIL Loop
* Condition is checked after the action.
* Commands are executed at least one time.
* Commands are executed repeatedly when the condition is true.

Starting State;
REPEAT
Commands
Increment / decrement
UNTIL (condition)

Anatomy of a Flowchart Loop

A flowchart loop doesn't have a special new symbol. Instead, it uses a Decision Diamond and a
Flow Line (Arrow) that goes back up.

• The Increment (Counter): Usually, we use a variable (like Count = Count + 1) to keep track
of how many times we have looped.
• The Arrow: Notice the arrow goes from the bottom back to the top. This creates a circle or
cycle.

Example 1: Count-Controlled Loop(For Loop)

Goal: Print the numbers 1, 2, 3, 4, 5. (Repeat exactly 5 times).


START

Pseudocode:
START
SET num TO 1
DECLARE num : INTEGER
FOR num := 1 TO 5 STEP 1
OUTPUT num
END FOR No
is num <= 5 ?
STOP
Yes
Flowchart Steps:
OUTPUT num
1. START
2. SET num TO 1
3. Decision: is num <= 5 ?
SET num TO num +1
* If Yes (True): Continue to STEP 4
* If No (False): Go to STOP
4. OUTPUT num
5. SET num TO num + 1 STOP
6. Loop Line: Go back to STEP 3
7. STOP

ICT Level 2 Page - 33


KMD Education Centre

Example 2: Condition-Controlled Loop (While Loop)


Goal: Print the numbers 1, 2, 3, 4, 5. (Repeat exactly 5 times). START

Pseudocode:
START SET num TO 1
DECLARE num : INTEGER
num := 1
WHILE num <= 5 DO
OUTPUT num No
is num <= 5 ?
num := num + 1
END WHILE
Yes
STOP
OUTPUT num
Flowchart Steps:

1. START
2. SET num TO 1 SET num TO num +1
3. Decision: is num <= 5 ?
* If Yes (True): Continue to STEP 4
* If No (False): Go to STOP
4. OUTPUT num STOP
5. SET num TO num + 1
6. Loop Line: Go back to STEP 3
7. STOP

Example 3: Condition-Controlled Loop (Repeat…Until Loop)


Goal: Print the numbers 1, 2, 3, 4, 5. (Repeat exactly 5 times).
START

Pseudocode:
START
DECLARE num : INTEGER SET num TO 1

num := 1
REPEAT
OUTPUT num OUTPUT num
num := num + 1
UNTIL num > 5
STOP SET num TO num +1

Flowchart Steps:
No
1. START is num > 5 ?
2. SET num TO 1
3. OUTPUT num Yes
4. SET num TO num + 1
5. Decision: is num > 5 STOP
• If No (False): Loop Line: Go back to STEP 3
• If Yes (True): Continue to STEP 6
6. STOP

Page - 34 ICT Level 2


KMD Education Centre
Example 4: Condition-Controlled Loop (While Loop)
START
Goal: Ask for a password until the user gets it right.

(We don’t know if they will try 1 time or 100 times).


OUTPUT "Enter Password: "

Pseudocode:
START INPUT pass
DECLARE pass : STRING
OUTPUT "Enter Password: "
INPUT pass
WHILE pass <> "secret" No is pass <>
OUTPUT "Wrong! Try Again" "secret"
INPUT pass
END WHILE Yes
OUTPUT "Welcome"
STOP OUTPUT "Wrong!
Try Again"

OUTPUT "Welcome!"

Flowchart Steps:
INPUT pass

1. START STOP
2. OUTPUT "Enter Password: "
3. INPUT pass
4. Decision: is pass <> "secret"
* If Yes (True): OUTPUT “Wrong! Try Again”. → Go back to Step 3(Input)
* If No (False): OUTPUT “Welcome!”. → Go to STOP.

Note: See how the NO arrow goes back up? That forces the user to try again. The program will
never end until they type "Secret".

Exercise 1: Trace the Loop


Look at Example 1 again. Fill in the Trace Table to see how the computer processes the loop.

Iteration (Round) num num: num <= 5? Output


1 1 True (Yes) 1
2 2 True (Yes) 2
3 3 __________ ______
4 4 __________ ______
5 5 __________ ______
6 6 False (No) (Loop Ends)

Exercise 2: Which Loop Type?

Read the scenarios below. Is it Count-Controlled or Condition-Controlled?

1. A program that prints the "Happy Birthday" song for every student in a class of 20.

ICT Level 2 Page - 35


KMD Education Centre

• Type: ____________________

2. A game that keeps playing until your "Lives" reach 0.

• Type: ____________________

3. A microwave spinning for exactly 60 seconds.

• Type: ____________________

4. Charging a phone until the battery is 100%.

• Type: ____________________

Exercise 3: Drawing Task

Draw a flowchart for an algorithm that displays the message "Hello World" exactly 10 times. (Hint:
Use a counter starting at 1 and a decision diamond to check if the count is <= 10).

Exercise 4: Trace the Output

Follow the flowchart logic below and write down the final output.
1. SET Num TO 0
2. SET Num TO Num + 2
3. OUTPUT Num
4. Is Num == 6?
• NO: Go back to Step 2.
• YES: Stop.

Your Answer (Output Sequence):

First Pass: 2
Second Pass: _____
Third Pass: _____ (Stop)

Page - 36 ICT Level 2


KMD Education Centre

Logic Challenge: Fix the Infinite Loop

A student wrote this algorithm to count down from 10 to 1. But it runs forever! Why?

The Code:

1. SET Count TO 10
2. OUTPUT Count
3. SET Count TO Count + 1 ← (Look closely here!)
4. IF Count = 0 THEN STOP
5. ELSE GO TO Step 2

The Error: __________________________________________________________________


(Hint: If you start at 10 and add 1, will you ever reach 0?)

Exam Practice

Question 1: Which flowchart feature creates a loop? Tick (✓) the correct answer. (1 mark)

A) ☐ A Decision Diamond with two exits going down.


B) ☐ A flow line (arrow) that points back to an earlier step.
C) ☐ A Terminator symbol at the start.

Question 2: Draw a flowchart snippet for a loop that asks a user to "Input a Number" and repeats
as long as the number is less than 0. (3 marks)
(Draw your flowchart here)

Question 3: Explain what is meant by the term "Iteration". (1 mark)

Answer: _________________________________________________________

ICT Level 2 Page - 37


KMD Education Centre

Unit 7: Computational Thinking & Algorithm Basics

Lesson 9 : Variable Tracking & Trace Tables (Thinking Like a Computer)


Learning Objectives:

By the end of this lesson, you will be able to:

• Explain what a Trace Table is and why programmers use it.


• Perform a "Dry Run" (testing code on paper) to track how variables change.
• Use a Trace Table to predict the Final Output of an algorithm.
• Find Logic Errors (bugs) by tracing step-by-step.

What is a Trace Table?

A Trace Table is a technique used to test an algorithm on paper to make sure it works correctly.
When you follow an algorithm line-by-line without using a computer, it is called a "Dry Run".

Why use Trace Tables?

• To find Bugs (errors) that the computer might not notice.


• To check if the Output is what you expected.
• To ensure your IPO Model (Input-Process-Output) is functioning correctly.

How to Build a Trace Table

A Trace Table is just a grid.


* Columns: Each column represents a Variable (e.g., Score, Total, Name) or the Output.
* Rows: Each row represents a Step or a change in the algorithm.

Example Layout:

Variable Variable
Step Instruction (Code) OUTPUT (Display)
A B
1 SET A TO 5 5 0
2 SET B TO 10 5 10
3 OUTPUT "Result is " + B 5 10 "Result is 10"

Example 1: Tracing a Simple Sequence


Let's trace a simple math program.

Algorithm: The Trace Table:


Step A B C OUTPUT
1. SET A TO 5
2. SET B TO 10 1 5 - - -
3. SET C TO A + B 2 5 10 - -
4. SET A TO C - 2 3 5 10 15 (Because 5 + 10 = 15)
5. OUTPUT A 4 13 10 15 (Because 15 – 2 = 13)
5 13 10 15 13

Page - 38 ICT Level 2


KMD Education Centre
Example 2: Tracing Selection (Pass/Fail)
We use this to check if our Branching logic is correct.

IF Score >= 40 THEN


OUTPUT "You Passed!"
Else
OUTPUT "Try Again!"
END IF

User Input
Condition: Score >= 40? Output Message
(Score)
80 True (Yes) "You Passed!"

40 True (Yes) "You Passed!"


35 False (No) "Try Again"

Example 3: Tracing a "REPEAT…UNTIL"

Trace tables are most useful for Loops (Lesson 8). Let's see how variables change during a loop.

The Algorithm:

1. SET X TO 1
2. REPEAT
3. OUTPUT X
4. SET X TO X * 2 (Multiply by 2)
5. UNTIL X > 5

The Trace Table:

Round X (Initial Value) Output X (Updated: X∗2) Condition: X>5?

1 1 1 2 False (Repeat)

2 2 2 4 False (Repeat)

3 4 4 8 True (STOP)

Exercise 1: Fill in the Blanks

Complete the trace table for this "Bank Balance" algorithm.

Algorithm: Your Trace Table:


1. SET Balance TO 100 Step Balance Withdraw OUTPUT
2. SET Withdraw TO 20 1 100
3. SET Balance TO Balance - Withdraw 2 100 20
4. SET Withdraw TO 30 3 80 20
5. SET Balance TO Balance - Withdraw 4 80 ____
6. OUTPUT Balance 5 ____ 30
6 ____

ICT Level 2 Page - 39


KMD Education Centre
Exercise 2: Find the Error (Debugging)

A student wrote a program to count from 1 to 3. But the output is wrong. Use a trace table to find
the bug.

The Buggy Algorithm: Trace It:

1. SET Count TO 1 Count Step 3 Step 4 Condition


2. REPEAT Round
(Start) (Count+1) (Display) (>3)?
3. SET Count TO Count + 1 1 1 2 2 No
4. OUTPUT Count 2 2 3 3 No
5. UNTIL Count > 3 3 3 4 4 Yes

The Result: It printed 2, 3, 4. The Goal: We wanted 1, 2, 3.


Question: Which two lines of code are in the wrong order?
Answer: Line ____ and Line ____ should be swapped.

Logic Challenge 1: The "Overwritten" Value

Look at this code:


1. SET A TO 10
2. SET B TO 20
3. SET A TO B
4. SET B TO A

Question: What are the final values of A and B?

A) A=20, B=10 (Swapped) Mini Trace Table


B) A=20, B=20 (Both same)
Step Variable A Variable B
1 10
2 10 20
3 20 20
4 20 __________

Challenge 2: The Logic Detective


Look at the following logic and fill in the trace table. What is the bug?
START
SET Score TO 0
WHILE Score < 3 Iteration Score Score < 3? Output
OUTPUT Score 1 0 True 0
END WHILE
STOP 2 0 True 0

Answer:

The variable Score is never updated (no SET Score TO Score + 1). This creates an Infinite Loop.

Page - 40 ICT Level 2


KMD Education Centre

Exam Practice

Question 1: Why do programmers use Trace Tables? (1 mark)


A) To run programs faster.
B) To test logic and find errors without a computer.
C) To design the user interface.

Question 2: Trace the following algorithm and state the final output. (2 marks)
SET N TO 5
SET N TO N + N
SET N TO N – 2
OUTPUT N
Final Output: ______________

Question 3: Why is a trace table useful before you start coding? (2 marks)

Answer: ________________________________________________________________________

Question 4: In a trace table, what does each row represent?

• A) A new variable.
• B) A new step or iteration of the loop.
• C) The final result only.

Question 5: Draw a Trace Table for a loop that runs 3 times, adding 5 to a Total (starting at 0) each
time. (3 marks)

(Draw your Trace Table here)

ICT Level 2 Page - 41


KMD Education Centre

Unit 7: Computational Thinking & Algorithm Basics

Lesson 10 : Totalling & Counting Algorithms(Doing Math Inside Loops)


Learning Objectives:

By the end of this lesson, you will be able to:

• Differentiate between Counting (1, 2, 3…) and Totalling (10 + 5 + 20…).


• Write algorithms that use Accumulators (running totals) inside loops.
• Understand Initialization (starting variable at 0).
• Trace variable changes inside a loop to calculate sums and averages.

Counting vs. Totalling

In programming, we often confuse these two actions. Let's clear it up using a "Shopping Cart"
example.

Feature Counting Totalling

Checking "How many?" items are in the


Purpose Adding up the "Values" of the items.
list.

Logic Add a fixed amount (usually +1). Add a variable amount (e.g., + Price).

Formula SET Count TO Count + 1 SET Total TO Total + Price

Adding up the total cost of items in a


Example Counting how many students are in a class.
cart.

The Rule of Initialization

Before using a variable for counting or totalling, you must set its starting value to 0.

• Why? To clear any "garbage values" (old data) left in the computer’s memory. If you don't
start at 0, your final answer will be wrong.

Example 1: Totalling (The Shopping Cart)


This algorithm calculates the total for 3 items.

Pseudocode:
START
DECLARE Total, Price, Round : INTEGER
SET Total TO 0 // Initialization
FOR Round := 1 TO 3 STEP 1
OUTPUT "Enter Price:"
INPUT Price
SET Total TO Total + Price // Totalling Logic
END FOR
OUTPUT "Your total is: " + Total
STOP

Page - 42 ICT Level 2


KMD Education Centre
Trace Table: (Assume Inputs: 10, 5, 20)

Round Price (Input) Total (Before) Total (Updated: Total + Price)


1 10 0 0 + 10 = 10
2 5 10 10 + 5 = 15
3 20 15 15 + 20 = 35

Example 2: Counting (Passing Students)

A teacher wants to enter marks for 10 students and Count how many students passed
(Marks >= 50).

Pseudocode:
START
DECLARE PassCount, i, mark : INTEGER
SET PassCount TO 0 // Start counter at 0
FOR i := 1 TO 10 STEP 1
OUTPUT “Enter your mark: ”
INPUT mark
IF mark >= 50 THEN
SET PassCount TO PassCount + 1 // Counting Logic
END IF
END FOR
OUTPUT "Number of students who passed: " + PassCount
STOP

Flowchart Logic:

1. START
2. SET PassCount TO 0 (Start counter at 0)
3. Loop 10 Times:
o INPUT Mark
o Decision: Is Mark >= 50?
▪ YES: SET PassCount TO PassCount + 1 (Add 1 to counter).
▪ NO: Do nothing.
4. End Loop
5. OUTPUT PassCount
6. STOP

Average Calculation

To find an Average, you need both logic types:

Average = Total (from Totalling) / Count (from Counting)

Exercise 1: Fill in the Blanks

Complete the logic for an algorithm that adds up all numbers from 1 to 5.

ICT Level 2 Page - 43


KMD Education Centre
1. SET Sum TO ______
2. SET Number TO 1
3. WHILE Number <= 5
4. SET Sum TO Sum + ______
5. SET Number TO Number + 1
6. ENDWHILE
7. OUTPUT Sum

Exercise 2: Complete the Flowchart

Goal: Calculate the Average score of 3 students. (Hint: Average = Total Score / 3)

Steps:

1. START
2. SET Total TO 0
3. Loop 3 Times:
• INPUT Score
• SET Total TO __________________ (Hint: Logic for totalling)
4. End Loop
5. SET Average TO Total / 3
6. OUTPUT Average
7. STOP

Challenge: The Average Calculator

To find the Average, you need both Totalling and Counting.


( Formula: Average = Total Sum / Count of Items )

Task: Write a simple Pseudocode that:

1. Asks for 5 numbers.


2. Calculates the Total.
3. Calculates the Average at the very end (outside the loop).

Exam Practice
Question 1: Which of the following represents a Totalling statement? (1 mark)

• A) SET X TO X + 1
• B) SET Total TO 0
• C) SET Total TO Total + NewValue
• D) OUTPUT Total

Question 2: Why is it important to set a "Total" variable to 0 before a loop starts? (2 marks)

Answer:__________________________________________________________________

Page - 44 ICT Level 2


KMD Education Centre
Question 3: Write the pseudocode formula to increment a counter by 1. (1 mark)

SET Count TO ____________________

Question 4: Look at the logic below. Is it Counting or Totalling? (1 mark)

SET BankBalance TO BankBalance + DepositAmount

• A) Counting
• B) Totalling

Question 5: Draw a flowchart snippet that checks IF Score < 40, then adds 1 to a variable named
FailCount. (3 marks)

(Hint: Draw a Diamond connected to a Rectangle)

ICT Level 2 Page - 45


KMD Education Centre

Unit 7: Computational Thinking & Algorithm Basics

Lesson 11 : Flowchart Mastery (The Missing Pieces)


Learning Objectives:

By the end of this lesson, you will be able to:

• Analyze a partial flowchart to determine its purpose.


• Identify missing symbols, arrows, or decision labels (YES / NO).
• Fix logic gaps to ensure the algorithm follows the IPO Model correctly.

The “Logic Detective” Strategy

In exams and real life, you are often given a flowchart with "holes" in it. To fill them correctly, follow
these three steps:

1. Read the Goal: What is the algorithm trying to achieve? (e.g., "Check a password" or
"Calculate a discount").
2. Trace the Path: Follow the arrows with your finger. Does the flow stop suddenly? Does it
skip a step?
3. Spot the Gap: Look for what's missing. Is it a Question (Diamond), an Action (Rectangle),
or a Result (Parallelogram)?

Common "Broken Logic" Scenarios

Even professional programmers make these mistakes! Look out for these errors in your exercises:

Error Type What is missing? The Result

The computer doesn't know which way to


The Silent Diamond No YES/NO labels on the arrows.
go.
A Process shape exists before any The computer tries to calculate data it
The Missing Input
Input. doesn't have yet.
An arrow that doesn't lead to another
The Dead End The program "crashes" or gets stuck.
shape or STOP.

The Infinite Loop A loop that has no "exit" condition. The program runs forever.

Filling the Gaps

Scenario: A student is building an algorithm for an Automatic Door.

• Rule 1: If a person is detected, the door opens.


• Rule 2: If no person is detected, it stays closed and keeps checking.

Task: Look at the diagram below and fill in the missing pieces (A, B, and C).

Page - 46 ICT Level 2


KMD Education Centre

START

No
A?

B?

C?

Fill in the blanks:


STOP

1. A (Diamond Question): _________________________________ (e.g., Person Detected?)


2. B (Label on Arrow): _________________________________ (e.g., YES)
3. C (Action/Process): _________________________________ (e.g., Open Door)

Exam Hack: The "Upstream" Arrow


When you see an arrow pointing backwards (upwards), it is always a Loop.

• Check: Does the loop have a way to end?


• Tip: If a flowchart asks you to "Repeat 5 times," ensure there is a Counter (e.g., SET Count
TO Count + 1) inside that loop!

Exam Practice

Question 1: Why must every Decision Diamond have exactly two exit arrows? (2 marks)

Answer: ________________________________________________________________________

Question 2: Look at the logic below. Which shape is in the wrong order? (2 marks)

START

SET Total TO Price + Tax

INPUT Price

STOP

Answer: The shape __________________ is wrong because _____________________________


_______________________________________________________________________________.
(Hint: Can you calculate the Total before you know the Price?)

ICT Level 2 Page - 47


KMD Education Centre

Unit 7: Computational Thinking & Algorithm Basics

Lesson 12 : Unit 7 Review & End of Unit Assessment (Mastering Algorithms)


Learning Objectives:

By the end of this lesson, you will be able to:

1. Review key concepts: IPO Model, Flowchart Symbols, and Pseudocode.


2. Demonstrate understanding of Sequence, Selection, and Iteration.
3. Apply Trace Tables to find errors and predict outputs.
4. Complete a formal assessment to prepare for the final exam.

Part 1: The "Cheat Sheet" (Quick Revision)

Use this summary to study before the exam.

1. The 4 Main Flowchart Symbols:

• Oval (Terminator): START / STOP.


• Parallelogram: INPUT (Get data) / OUTPUT (Display info).
• Rectangle (Process): Calculations (e.g., Total = A + B) or Assigning Variables.
• Diamond (Decision): Asking a Question (Yes/No). Used for IF and Loops.

2. The 3 Building Blocks of Logic:

• Sequence: Steps happen one after another.


• Selection: Making a choice (IF...THEN...ELSE).
• Iteration (Looping): Repeating code (FOR loops or WHILE loops).

3. Variables & Loops:

• Variable: A named box to store data (e.g., Score, Name).


• Initialization: Always set counters/totals to 0 before a loop starts.
• Totalling: Total = Total + Price
• Counting: Count = Count + 1

Page - 48 ICT Level 2


KMD Education Centre

Part 2: End of Unit Assessment

(Time Allowed: 45 Minutes)

Section A: Multiple Choice (10 Marks)

1. Which symbol is used to ask a question in a flowchart?

A) Rectangle
B) Parallelogram
C) Diamond
D) Oval

2. What is an "Algorithm"?

A) A type of computer virus.


B) A step-by-step set of instructions to solve a problem.
C) A fast computer processor.
D) A graphical drawing tool.

3. In the IPO model, calculating Area = Length * Width belongs to:

A) Input
B) Process
C) Output
D) Storage

4. Which loop is best when you know EXACTLY how many times to repeat?

A) Condition-Controlled Loop (While)


B) Count-Controlled Loop (For)
C) Infinite Loop
D) Selection Loop

5. What is the error called when a program runs but gives the wrong answer?

A) Syntax Error
B) Logic Error
C) Hardware Error
D) User Error

ICT Level 2 Page - 49


KMD Education Centre

Section B: Short Answer Questions (10 Marks)

6. Explain the difference between a Variable and a Constant. (2 marks)

Answer: ___________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________

7. Look at the pseudocode below. What is the final output? (3 marks)

SET X TO 5
SET Y TO 10
SET X TO Y
SET Y TO X
OUTPUT Y

Answer: ____________________

8. Write the Pseudocode to check if a student passed. (3 marks)

If Score is greater than or equal to 50, Display "Pass".


Else, Display "Fail".
(Write your pseudocode here):
Answer: ____________________________________________
____________________________________________________
____________________________________________________
____________________________________________________
____________________________________________________

9. Why do we use Trace Tables? (2 marks)

Answer: ____________________________________________
____________________________________________________
____________________________________________________

Page - 50 ICT Level 2


KMD Education Centre

Section C: Practical Skills (Drawing & Tracing) (20 Marks)

10. Trace the Loop (10 Marks) Complete the trace table for the following algorithm:
Logic:

1. SET Total TO 0
2. SET Count TO 1
3. WHILE Count <= 3
4. SET Total TO Total + (Count * 2)
5. SET Count TO Count + 1
6. END WHILE
7. OUTPUT Total

Round Count Count <= 3? Calculation (Total + ...) New Total

1 1 YES 0 + (1*2) 2

2 2 YES 2 + (2*2) 6

3 3 YES 6 + (**) ******

4 4 NO - ____

Final Output: _______________

11. Draw the Flowchart (10 Marks)


Scenario: A coffee machine program.

1. Start.
2. Ask user: "Enter Sugar Level (0-3)".
3. Input Sugar.
4. Check: Is Sugar > 3?
• YES: OUTPUT "Too much sugar!" and go back to Step 2 (Input).
• NO: OUTPUT "Dispensing Coffee...".
5. Stop.

(Draw your flowchart in the box below)

ICT Level 2 Page - 51

You might also like