Professional Documents
Culture Documents
2 1 2 Structure Chart
2 1 2 Structure Chart
A Structure Chart in software engineering is a chart which shows the breakdown of a system to its lowest
manageable parts. They are used in structured programming to arrange program modules into a tree.
Each module is represented by a box, which contains the module's name. The tree structure visualizes the
relationships between modules, showing data transfer between modules using arrows.
Page 1 of 8
Computer Science 9608 (Notes)
Chapter: 2.1 Algorithm design and problem-
solving
components.
Module Each Box represents a programming module, this might be something that calculates the average of
Process
Name some figures, or prints out some pay slips
Data
Data being passed from module to module that needs to be processed.
Couple
[Extension - you don't need to know this for the exam] Check data sent to process to stop or start
Flag processes. For example when the End of a File that is being read is reached, or a flag to say whether
data sent was in the correct format
Let's take a look at a simple example of how this might be executed when representing the following code:
3T 3T 10T
Sub calculateAverage()
3T 3T 3T 3T4
inputNums()
47T 47T 10T 10T 10T
outputAvg(avg)
3T
end sub
3T 3T 10T 10T 10T
function average(a,b)
3T 10T3 10T 47T 47T 10T 10T47 40T7
return(a + b)/2
3T
end function
3T 3T 10T
subinputNums()
3T 3T 3T 3T4
num1 = console.readline()
47T 47T 47T 36T47 10T36
num2 = console.readline()
3T
end sub
3T 3T 10T 10T 10T
suboutputAvg(x)
47T 36T47 10T36 10T45 45T7 47T 10T
console.writeline("average = "& x)
3T
end sub
Page 2 of 8
Computer Science 9608 (Notes)
Chapter: 2.1 Algorithm design and problem-
solving
sub main()
3T 3T 3T 3T4
sayHello()
47T 40T7
num1 = 34
47T 40T7
num2 = 89
47T 47T 10T 10T 10T
end sub
3T 3T 10T 10T 10T
function average(a,b)
3T 10T3 10T 47T 47T 10T 10T47 40T7
return(a + b)/2
3T
end function
3T 3T 10T
sub sayHello()
47T 36T47 10T36 10T45 10T45
console.writeline("hello")
3T
end sub
Page 3 of 8
Computer Science 9608 (Notes)
Chapter: 2.1 Algorithm design and problem-
solving
Answer
Page 4 of 8
Computer Science 9608 (Notes)
Chapter: 2.1 Algorithm design and problem-
solving
Selection
A selection in a Structure Chart is determined by the diamond symbol. This means a condition will be
checked and depending on the result, different modules will be executed.
3T 3T 10T
sub main()
3T 3T 3T 3T4
num1 = console.readline()
3T 3T 47T 40T7 3T40
if num1 = 7 then
10T
luckyNumber()
3T
else
10T
otherNumber()
3T
endif
3T
end sub
Page 5 of 8
Computer Science 9608 (Notes)
Chapter: 2.1 Algorithm design and problem-
solving
The arrow encompasses a link to a module, implying that module is executed multiple times. Let's take a
look at a coded example:
3T 3T 10T
sub main()
3T 3T 3T 3T4
num1 = console.readline()
3T 3T 47T 40T7 3T40
num1 = countdown(num1)
3T
end while
3T
end sub
3T 3T 10T 10T 10T
sub countdown(a)
3T 3T 47T 40T7
return (a-1)
3T 3T
end sub
Page 6 of 8
Computer Science 9608 (Notes)
Chapter: 2.1 Algorithm design and problem-
solving
Sub howManyThrees()
3T 3T 3T 3T4
num1 = startMsg()
47T 40T7
count = 0
47T 40T7
total = 0
3T 3T 47T 40T7 3T40
num1 = num1 -1
3T
end while
10T 10T 10T
endMsg(count)
3T
end sub
3T 3T 10T 10T3 3T 3T 3T 3T 3T 10T
If n MOD 3 = 0 Then
47T 47T 10T 10T 10T
c = divBy3(c)
3T
Else
47T 47T 10T 10T 10T
t = add(n, t)
3T
EndIf
3T
End sub
3T 3T 10T 10T 10T
function divBy3(x)
3T 3T 47T 40T7
return x +1
3T
end function
3T 3T 10T 10T 10T
function add(n, t)
3T 3T 47T 47T
return n + t
3T
end function
3T 3T 10T
function startMsg()
47T 36T47 10T36 10T45 10T45
return console.readline()
3T
end function
3T 3T 10T 10T 10T
sub endMsg(n)
47T 36T47 10T36 10T45 45T7 47T 10T
end sub
Page 7 of 8
Computer Science 9608 (Notes)
Chapter: 2.1 Algorithm design and problem-
solving
Answer :
Page 8 of 8