10
Program Flow Control

1. Know the different types of flow block 2. Understand how problems can be broken down into smaller problems

Embed Size (px)

Citation preview

Page 1: 1. Know the different types of flow block 2. Understand how problems can be broken down into smaller problems

Program Flow Control

Page 2: 1. Know the different types of flow block 2. Understand how problems can be broken down into smaller problems

1. Know the different types of flow block

2. Understand how problems can be broken down into smaller problems

Learning Objectives

Page 3: 1. Know the different types of flow block 2. Understand how problems can be broken down into smaller problems

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

Page 4: 1. Know the different types of flow block 2. Understand how problems can be broken down into smaller problems

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

Page 5: 1. Know the different types of flow block 2. Understand how problems can be broken down into smaller problems

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:

Page 6: 1. Know the different types of flow block 2. Understand how problems can be broken down into smaller problems

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

Page 7: 1. Know the different types of flow block 2. Understand how problems can be broken down into smaller problems

Flowchart Example

Turn A/C off

False

Turn on A/C

True

Temp > 25

End

Start

Temp

Page 8: 1. Know the different types of flow block 2. Understand how problems can be broken down into smaller problems

Flowchart Selection (IF Statement)

So how do you do an if statement?

Is it holidays?

YAY!!! Holidays

Booooo

No/FalseYes/True

Page 9: 1. Know the different types of flow block 2. Understand how problems can be broken down into smaller problems

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

Page 10: 1. Know the different types of flow block 2. Understand how problems can be broken down into smaller problems

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