Upload
owen-walsh
View
213
Download
0
Embed Size (px)
Citation preview
Program Flow Control
1. Know the different types of flow block
2. Understand how problems can be broken down into smaller problems
Learning Objectives
Structured programming is IMPORTANT because it usually makes programs more reliable, easier to read, understand and maintain.
Complex problems are easier to solve as they are broken down into smaller, more practicable steps.
How can we add structure to programs?
Structure
There are only four fundamental building blocks in programing
1. Sequencing – the order in which statements are executed
2. Selection – the use of logic to select the statement to be executed
3. Iteration – the use of repetition (being lazy!!)
4. Variables – somewhere to store information at run time, very very useful
Building Blocks
Sequence
Temperature Conversion
Input temperature in
Fahrenheit
Calculate Temperature Conversion
Output Temperature in
Centigrade
Statements are executed in the order they are written in the program. Here there a 3 steps and they occur in this order:
Flow charts easily show how the flow of the sequences happen
There are lots of different shapes that make a flow diagram, we are only likely to use 5
Flow Charts
Flow Arrow
Input Block
Flowchart Example
Turn A/C off
False
Turn on A/C
True
Temp > 25
End
Start
Temp
Flowchart Selection (IF Statement)
So how do you do an if statement?
Is it holidays?
YAY!!! Holidays
Booooo
No/FalseYes/True
We are going to have to model a loop as well.
How do you think that we do loops?
Flowchart Iteration (Loops)
Turn A/C off
False
Turn on A/C
True
Temp > 25
Start
Temp
In groups of 2 You are going to come
up with a flow diagram to show how to make a cup of tea
We are then going to run your programs in the next lesson.
Remember - think about all of the tasks to make
the tea
Tea-bot Task