Information Technology Topic
Flowcharts: Symbols and Flow
- Read notes
- Flashcards
- Quiz
- Confident
Study focus - 3 things
- Flowchart symbols: a parallelogram for input or output, a rectangle for a process and a diamond for a decision, joined by arrows that show the flow (a rounded terminal marks Start and Stop)
- A decision diamond has two labelled ways out, Yes and No, and a loop is drawn by sending an arrow back from later in the flow to the decision so the test is made again
- To read a flowchart, start at Start, follow the arrows, answer each decision from the data and track the variables; to draw one, give each step the right symbol and an arrow
Visual notes
The four symbols and the arrow used in this topic, with the pseudocode keywords that belong in each.
A selection drawn as a flowchart. The diamond has one way in and two labelled ways out; both paths join again before Display bonus.
A loop drawn as a flowchart. The arrow that runs up the left side returns to the diamond, so the test is made again before every pass.
Section 1What a flowchart is
A flowchart is a diagram of an algorithm. Each step is drawn inside a shape and arrows join the shapes in the order the steps happen. The shape tells you what kind of step it is, so a reader can follow the plan without reading a paragraph. A flowchart is one of the two ways the syllabus asks you to show an algorithm. The other is pseudocode. The same algorithm can be drawn as a flowchart or written as pseudocode, and both should give the same results. The arrows are the flow of control. They show which step comes next.
Section 2The symbols
Four kinds of shape, plus arrows, do the whole job (see the symbol key above). Terminal (rounded rectangle): marks where the flowchart starts and where it stops. Write Start in the first one and Stop in the last. Input/output (parallelogram): data comes in or goes out, as in Read sales or Display bonus. Process (rectangle): something is done to the data, such as a calculation or a Store step like Store sales * 0.04 in bonus. Decision (diamond): a test that is answered Yes or No, such as sales > 30000? It has two exits. Flow lines (arrows): join the symbols and show the direction of flow. Here's the trick: ask what the step does. Data in or out is a parallelogram, work done on the data is a rectangle, and a choice is a diamond.
Section 3Reading a flowchart: a decision
To read a flowchart, start at Start and follow the arrows. Keep a note of the value of each variable as you go. Use the bonus flowchart in the first diagram. A Montego Bay call centre pays a bonus of 4% of sales when sales are over 30000. Take sales of 45000. Read sales stores 45000. The diamond asks 45000 > 30000? and the answer is Yes, so follow the Yes arrow to Store sales * 0.04 in bonus, which gives 1800. Display bonus shows 1800 and the flowchart reaches Stop. Now take sales of exactly 30000. The test 30000 > 30000? is No, because 30000 is not greater than itself. The No arrow gives a bonus of 0. Watch out: only one of the two paths is followed on any run, never both.
Section 4Decisions: two labelled ways out
A decision diamond is where the path splits. Two arrows leave it, one labelled Yes (the test is true) and one labelled No (the test is false). Without the labels a reader cannot tell which exit to take. Write the test so that a Yes or No answer makes sense: sales > 30000? or age <= 12? An instruction such as Store 0 in bonus belongs in a rectangle, not in a diamond. The two paths usually join again further down, as the Yes and No paths do before Display bonus in the first diagram. Easy to mix up: the boundary. For > the exact limit gives No. If the limit itself should earn the bonus, the test must be sales >= 30000?
Section 5Loops in a flowchart
A loop is a decision plus an arrow that goes back. In the second diagram the diamond asks count <= 3? and the Yes arrow runs down through Read num, Store total + num in total and Store count + 1 in count. From that last rectangle an arrow runs back to the diamond. The test is made again before every pass. Trace it with the numbers 10, 20 and 30. The diamond is reached with count 1 and total 0, then with count 2 and total 10, then with count 3 and total 30, and each time the answer is Yes. After the third pass count is 4 and total is 60. The fourth time the diamond is reached the answer is No, so Display total shows 60 and the flowchart stops. The diamond is tested 4 times but the body of the loop runs 3 times, and the arrow that goes back is followed 3 times. Here's the trick: the arrow goes back to the diamond, not to Start and not to the step after it.
Section 6Drawing a flowchart
1. List the steps of the algorithm in order. 2. Choose a symbol for each step: data in or out is a parallelogram, a calculation or a Store is a rectangle, a choice is a diamond. 3. Begin with a Start terminal and end with a Stop terminal. 4. Join the symbols with arrows, running down the page where you can, and put an arrowhead on every line. 5. Give every diamond two exits and label them Yes and No. 6. For a loop, send an arrow back to the diamond that tests the condition. 7. Test the flowchart by following the arrows with sample data. A good check: every symbol except Stop has an arrow leaving it, a diamond has two, and every other symbol has exactly one.
Section 7Flowchart and pseudocode side by side
Each pseudocode statement has a matching symbol. Read and Input go in a parallelogram. Write, Output and Display also go in a parallelogram. Store goes in a rectangle. The test of an If-then or If-then-else goes in a diamond with a Yes exit and a No exit. A While loop is a diamond tested before the body, with an arrow back from the body to the diamond. A For loop has no symbol of its own. It is drawn as a counting loop: Store the start value in a count, a diamond that tests the count against the end value, the body, Store count + 1 in count, and an arrow back to the diamond. The loop flowchart above is the same as this pseudocode: Store 0 in total Store 1 in count While count <= 3 Read num Store total + num in total Store count + 1 in count End While Display total Both give 60 for the numbers 10, 20 and 30.
Examples
A Montego Bay call centre uses the bonus flowchart in the visual notes: Start, Read sales, a diamond sales > 30000?, a Yes path to Store sales * 0.04 in bonus, a No path to Store 0 in bonus, Display bonus, Stop. (a) For sales of 45000, list the symbols visited in order and state the bonus displayed. (b) Repeat for sales of 30000. (c) The manager wants a sales figure of exactly 30000 to earn the bonus. State the change to make, and the bonus displayed for 30000 after the change.
(a) Start, Read sales (a parallelogram), the diamond, then the Yes exit, the rectangle Store sales * 0.04 in bonus, Display bonus (a parallelogram) and Stop. The test 45000 > 30000 is Yes, and 45000 * 0.04 = 1800. The bonus displayed is 1800. (b) The same symbols are visited, but 30000 > 30000 is No, so control takes the No exit to Store 0 in bonus. The bonus displayed is 0. (c) Change the test in the diamond to sales >= 30000? Now 30000 >= 30000 is Yes, so the bonus is 30000 * 0.04 = 1200. Only the operator changed, but it moved the boundary.
A teacher in Portmore adds three scores using the loop flowchart in the visual notes: Start, Store 0 in total, Store 1 in count, a diamond count <= 3?, then Yes to Read num, Store total + num in total, Store count + 1 in count and an arrow back to the diamond, and No to Display total, Stop. The scores entered are 12, 7 and 9. (a) Show the values of count and total each time the diamond is reached, and the answer to the test. (b) State what is displayed. (c) State how many times the diamond is tested and how many times the arrow back to it is followed. (d) The test is changed to count < 3? State what is displayed now.
(a) Diamond reached 1: count 1, total 0, Yes (read 12, total becomes 12, count becomes 2). Diamond reached 2: count 2, total 12, Yes (read 7, total 19, count 3). Diamond reached 3: count 3, total 19, Yes (read 9, total 28, count 4). Diamond reached 4: count 4, total 28, No. (b) The No exit leads to Display total, which shows 28. (c) The diamond is tested 4 times. The body runs 3 times, so the arrow back is followed 3 times. (d) With count < 3? the answer is Yes for count 1 and 2 and No for count 3. Only 12 and 7 are read, so 19 is displayed. The loop ran one pass too few, which is why the operator and the limit must be checked.
Now let's water it
Session runs notes to flashcards to quiz back-to-back.
Where this comes from
- CSEC Information Technology Syllabus (CXC 30/G/SYLL 08, revised 2000, 2008, 2013) · Caribbean Examinations Council (CXC) · Section 2, Specific Objective 6 · Syllabus scope
- Navy Electricity and Electronics Training Series (NEETS), Module 22, Introduction to Digital Computers (NAVEDTRA 14194, September 1998) · US Navy (Naval Education and Training Professional Development and Technology Center) · Module 22, Chapter 3 Flowcharting, Figure 3-3 Fundamental flowcharting symbols (process, input/output, decision, terminal, connector and flow line; arrowheads needed when flow is not the normal direction; a 1998 Navy training text), checked against (https://vtda.org/bits/other/US_Navy/NEETS/US%20Navy%20NEETS%20-%20Module%2022-Introduction%20to%20Digital%20Computers%20NAVEDTRA%2014194.pdf) · Facts
- Navy Electricity and Electronics Training Series (NEETS), Module 22, Introduction to Digital Computers (NAVEDTRA 14194, September 1998) · US Navy (Naval Education and Training Professional Development and Technology Center) · Module 22, Chapter 3 Flowcharting, Figure 3-3 and Figure 3-6 (a decision with a NO branch that sends flow back to an earlier processing block, so a step is repeated), checked against (https://vtda.org/bits/other/US_Navy/NEETS/US%20Navy%20NEETS%20-%20Module%2022-Introduction%20to%20Digital%20Computers%20NAVEDTRA%2014194.pdf) · Facts