Professional Documents
Culture Documents
Unit 3 Flowchart & Activity Diagram
Unit 3 Flowchart & Activity Diagram
Learning objectives
Learning outcomes
A student should be able to use a diagram to explain their solution to a given problem
Flowchart
Terminal: The terminal symbol indicates the start or end of an algorithm. The following
figures show the symbol and the usage example.
Start
Terminal
Figure 3.1a: Terminal symbol
End
Figure 3.1b: Terminal symbol indicating the start
Page 1
Unidirectional arrow: The unidirectional arrow indicates the flow of the process in the
algorithm. The following figure shows the unidirectional symbol.
Input & Output: The input & output symbol represents an input or output from the
algorithm. The following figures show the symbol and the usage example.
start
input & utput
print totalScore
Figure3.3a: Input/output symbol
input caScore, examScore
end
Processing symbol: The processing symbol represents any internal processing step to solve a
given problem, such as initialization of variables and arithmetic operation. The following
figures show the processing symbol and its usage example.
Decision
Page 2
totalScore = caScore + examScore
false true
(totalScore < 40)
end
Figure 5b: Decision symbol used to decide what path to take depending on the value of totalScore. The decision tests
whether or not the totalScore is less than forty (40); If true, the path to Print fail will be followed; if false the path to Print pass
will be followed.
start
counter = 0
false true
(counter < 6)
Print totalScore
counter = counter +1
Figure 3.5c: Decision symbol used to repeat the branching to the true path of the flowchart six (6) times. First, the counter is
initialized to zero (0). The decision tests whether or the counter is less than six (6); If true, caScore and examScore will be
taken as inputs. Next, the caScore and the totalScore are added; the result is assigned to totalScore. Next, the totalScore is
printed as output. Lastly, the counter is incremented by 1. The repetition continues until the counter is no longer less than
six(6). In that case, the false path or branch, which leads to the end, will be followed.
Page 3
Connector Symbol
The connector symbol is used to connect a break in a flowchart. Figure 3.6a depicts the
connector symbol. The flowchart of Figure 3.6b is broken at the point A (because the
flowchart is not complete), and from which the flowchart in Figure 3.6c connects to (the
flowchart in Figure 3.6c is the completion of the flowchart in Figure 3.6b).
start
Figure 3.6b: a flowchart broken at point A Figure 3.6b: a flowchart connected to the flowchart of Figure 3.6b
at point A
Flowchart examples
Example 3.1: Using a flowchart, describe an algorithm for finding the sum of two numbers.
Solution:
Start
input firstNumber
input secondNumber
print sum
Stop
Page 4
Example 3.2: Using a flowchart, describe an algorithm that accepts three numbers as input
and output the highest number among the three.
Start
input numb1
input numb2
input numb3
high = numb1
true
if (high < numb2)
true
if (high < numb3)
high= numb3
false
print high
Stop
Example 3.3
Using a flowchart, describe an algorithm that prints integer numbers from 1 to 100.
Solution:
Start
.
counter = 1
Print counter
counter = counter+1
Stop
Page 5
Class Activity
Elite Guru has opened a branch at Al-Qalam University Market place and 20 Software
Engineering students rushed to make purchases. The following is an algorithm to compute the
total of 1% discount that may be given to 20 students. Sketch the flowchart for the algorithm.
totalDiscount = 0
counter = 1
input totalCostOfItems
discount = (1/100)*totalCostOfItems
else
discount = 0;
end if
end while
print totalDiscount
3.2 Exercises
b2 4ac
Hint x b
2a
4. Using a flowchart, describe an algorithm that accepts three unknown numbers and out
put the lowest among the three.
5. Using a flowchart, describe an algorithm to calculate 4!
Page 6
6. Using a flowchart, describe an algorithm that accepts a student score and prints the
score grade using the following table.
Score Grade
0 – 39 F
40 – 49 D
50 – 59 C
60 – 69 B
70 – 100 A
Page 7