Download presentation
Presentation is loading. Please wait.
1
Print slides 15-17 for students reference
Flow Charts Print slides for students reference
2
Lesson Objectives Aims
Be able to define the terms “Sequence” “Selection” and “iteration” To understand the basic flow chart symbols To be able to construct a flow chart for a given algorithm To be able to convert an algorithm or set of instructions in to a flow chart
3
Flow charts What is an algorithm? Last lesson we wrote out sets of steps that would solve some simple problems Can anyone remember any of the algorithms we looked at?
4
Algorithm Key Terms In your final task last lesson, we had to create an algorithm which worked out the average height of 30 people. This involved: Doing things in a certain order Making decisions Doing things over and over again (repetition) It just so happens there are key words you need to know the definitions of for these three things.
5
Sequence Sequence or sequencing: Selection Iteration
Placing instructions in the correct order Selection Making a decision and allowing different actions to be taken depending on the outcome Iteration Doing things repeatedly, or going back to a certain point in an algorithm/program These are nailed on exam questions, make sure you copy them down and learn them
6
Another way… Although sometimes it is easy to just write a set of steps that work, it can be difficult To arrive at that set of steps it can often be helpful to visualise the process using a diagram This can help us debug and test a set of instructions before coding
7
Symbols New heading “Flow Charts” Put a sub heading for each symbol Draw the symbol and give a short explanation of each
8
Start Stop Start/Stop Indicates the beginning and end of a diagram
All flow charts MUST have one start symbol and at LEAST one stop. Only one line can be drawn from a start symbol Many lines may go to one stop symbol Start Stop
9
Xposition = Xposition - 5
Process (sequencing) Indicates something which the program must do. Should always be a simple statement – complex processes need to be broken down into more boxes or even their own diagram Xposition = Xposition - 5 Turn motor A off
10
Input/Output (Sequencing)
Indicates when a program will get input or produce output Should show messages that will be displayed Indicate output messages Could name sensors or other data sources Useful to indicate variable names Name = User Input Output Final Score Ask “is the object round?”
11
Decision (Selection, Iteration)
Used to indicate where a decision is made in a program Directly relate to IF statements Or used when creating a loop MUST have a YES and a NO output, no exceptions Is score > high score? NO YES
12
Sub Process Occasionally algorithms may be too complex to represent in one long chart You can put this box in and then make a new, separate flow chart for that part of your algorithm Sub-process
13
Some Examples Stop Start NO YES YES NO Get symptom
Is the patient breathing? NO Call ambulance Output “Patient is probably dead, Jim” Stop YES Is the patient a funny colour? Is it Orange? YES Output “Too much fake tan” NO
14
Here’s one I stole from the internet
15
Reading a Flowchart Start Is total > 10? No INPUT x Yes INPUT y
OUTPUT total OUTPUT x * y total = x + y End What will be the result if 2 and then 4 are input? What will be the result if 5 and 8 are input?
16
Reading a Subroutine What will be output if the following numbers are entered in this order: What will be output if the following numbers are entered in this order: Start Reduce (num) INPUT num1 INPUT value Count = 0 value = num - value Reduce(num1) OUTPUT value Count = Count + 1 End No Yes Is Count > num1? End
17
A note on variables Whenever we need to store a value in a program we use a variable A variable is simply a container for a number or some text It is EXACTLY the same as algebra in maths : T = 5 x = x + y We give them descriptive names, for example “age” “weight” “totalScore” We will come back to them in a later lesson (in 2.2)
18
Loops (ITERATION) – “For” style loop
We need a variable to keep track of how many times the loop needs to go round Set counter = 0 Is counter < 50 This would be many steps in a real loop, so you wouldn’t just draw one box like this! YES Do loop actions… NO Increase the counter by 1 – if we don’t do this the loop will never end. Counter = Counter + 1 If the counter has reached our target (50) then the loop has ended and we jump to the next set of instructions/steps Things to do after the loop…
19
Your turn Last lesson you created an algorithm which would calculate the average height of 30 students Using your notes and what you’ve learned this lesson, turn this in to a flow chart Highlight in another colour which sections of your flow chart represents sequencing, selection and iteration
20
Task 2 Create and draw a flow chart for this algorithm:
In an algorithm for a guessing game, the computer generates a random number between 1 and 10. The player has to guess the number and enter it, and then they are informed if it is correct. If after three guesses they have not guessed the correct number, they are informed that they have run out of guesses and the correct number is displayed.
21
Create a flow chart for this scenario:
Homework Create a flow chart for this scenario: A teacher collects the marks of a test, there are 25 students He wants a program which will: Get each mark If it is less than 25, display “Fail, resit needed” If it is between 25 and 50 display, “Pass, well done” If it is over 50, display “High level pass, well done” It should count and display the number of fails, passes and high passes at the end of the program Hint – you will need to use variables to count the passes, fails etc
25
Review/Success Criteria
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.