LearnWave
Learn it. Master it.

Introduction to Problem Solving

Flowcharts and pseudocode

Draw the flowchart and write the pseudocode for an algorithm.

An algorithm can be shown in two ways: as a flowchart (a picture) or as pseudocode (text). Both show the logic and the flow of control, not the details of any particular programming language.

A flowchart uses standard symbols (Table 4.1):

  • Oval: start or end (the terminator).
  • Rectangle: a process (an action, such as a calculation).
  • Diamond: a decision (a question with yes/no answers).
  • Parallelogram: input or output of data.
  • Arrow: the order in which the steps are followed.

For example, to find the cube of a number: Step 1, input num (parallelogram); Step 2, cube = num × num × num (rectangle); Step 3, print cube (parallelogram); all between a Start and an End oval.

Pseudocode means 'not real code'. It describes the steps in plain, informal language for people to read; a computer cannot execute it. Common keywords: INPUT, COMPUTE, PRINT, INCREMENT, DECREMENT, IF/ELSE, WHILE, TRUE/FALSE.

Pseudocode helps programmers not to miss any step, and lets people who do not program review the logic. An example, to find the area and perimeter of a square:

  • INPUT side
  • COMPUTE Area = side * side
  • COMPUTE Perimeter = 4 * side
  • PRINT Area, Perimeter
Diamond decides, rectangle does, parallelogram inputs.
Diamond decides, rectangle does, parallelogram inputs.

Practise this lesson

Questions that get harder as you improve, a Tutor that helps without giving the answer away, and progress you can see. Free for every learner.

No account, no email address. Opens the real product.