• Foundation
  • About 12 min
  • 5 practice questions

Algorithms and flowcharts

Define an algorithm, write one in plain steps and read basic flowchart symbols.

If something looks wrong, please tell us.

Before writing any program, a programmer plans the steps. That plan is an algorithm, and a picture of it is a flowchart.

Algorithm

An algorithm is a finite, step-by-step set of instructions to solve a problem. A good algorithm is clear, has a definite start and end, takes input (possibly), produces output and is finite, meaning it must stop.

Algorithm to find the sum of two numbers: 1. Start. 2. Read A and B. 3. Add: Sum = A + B. 4. Print Sum. 5. Stop.

Flowchart symbols

Symbols
SymbolNameUsed for
OvalTerminatorStart and Stop
ParallelogramInput / OutputReading and printing data
RectangleProcessCalculations and assignments
DiamondDecisionYes/No question with two exits
ArrowFlow lineDirection of flow
CircleConnectorJoining parts of a chart

Pseudocode

Pseudocode is a plain-language outline of a program that is not tied to any language. It is easy to read and convert to real code.

Worked examples

Example 1. Algorithm for the area of a rectangle. Start; read length L and breadth B; Area = L x B; print Area; stop. For L = 8 and B = 5, Area = 40.

Example 2. Which flowchart symbol holds the question 'Is the number greater than 10?' The diamond (decision).

Example 3. Average of three numbers 4, 8 and 12. Sum = 24; Average = 24 / 3 = 8.

Algorithm = steps. Flowchart = picture of the steps. Pseudocode = steps in plain words.

— Remember

Key takeaways

  • Plan with an algorithm before coding.
  • Know the flowchart symbols.
  • Pseudocode is language-free.

Check your understanding

  1. 1. Which flowchart symbol holds a yes/no question such as 'Is the number greater than 10?'

    1. Oval
    2. Diamond
    3. Rectangle
    4. Parallelogram
    Show answer

    Answer: B. A decision is drawn as a diamond with two exits, Yes and No.

  2. 2. Which flowchart symbol is used for reading and printing data?

    1. Diamond
    2. Parallelogram
    3. Oval
    4. Circle
    Show answer

    Answer: B. Input and output are shown with a parallelogram.

  3. 3. An algorithm reads length L and breadth B and prints Area = L x B. What does it print for L = 9 and B = 6?

    1. 54
    2. 15
    3. 30
    4. 96
    Show answer

    Answer: A. Area = 9 x 6 = 54. (15 is L + B and 30 is 2 x (L + B), the perimeter.)

  4. 4. What is the average of 6, 9 and 15?

    1. 30
    2. 15
    3. 10
    4. 9
    Show answer

    Answer: C. Sum = 6 + 9 + 15 = 30. Average = 30 / 3 = 10.

  5. 5. Pseudocode is

    1. A program written in 0s and 1s
    2. A flowchart symbol for decisions
    3. A plain-language outline of a program that is not tied to any language
    4. A kind of compiler
    Show answer

    Answer: C. Pseudocode describes the steps in plain words, independent of any language, so it is easy to read and convert to real code.

Sign in to keep track of the lessons you finish.

Next lesson → Variables, data types and operators

Privacy · Terms · Refunds · Delivery