Unit 1 · Basics of Computer Programming

1.2.3Self-check and practice

Self-check questions

Write your answers first, then open the answers to check them.

  1. Which symbol is used for a decision? How many exits must it have?
  2. How is a loop shown in a flowchart?
  3. What is the purpose of a connector?
Show answers
  1. The diamond (decision). It must have exactly two exits, labelled Yes/No or True/False.

  2. With a decision diamond and an arrow that returns to a point before the diamond. One exit leads into the loop body and back up again; the other exit leaves the loop.

  3. A connector (a small circle with a letter or number) joins two parts of a flowchart: for example when the chart continues on another page, or when a flow line would otherwise cross other lines.

Practice exercises

  1. Draw a flowchart to find the largest of three numbers.
  2. Draw a flowchart to print the multiplication table of a number N (1 to 10).
  3. Draw a flowchart that reads marks and prints Pass (50 or more) or Fail.
  4. Draw a flowchart that keeps reading numbers until the user enters 0, then prints their sum.
  5. Draw a flowchart for a grading system: A (75+), B (65 to 74), C (50 to 64), F (below 50).
    Hint

    Chain three decision diamonds: marks >= 75? If No, marks >= 65? If No, marks >= 50? Each Yes exit leads to a process box that sets the grade.