Flow Charts & Pseudocode

Flowchart Symbols

A flowchart is a diagram of an algorithm. It should show the order of steps, where input and output occur, where decisions branch, and where loops return.

Start / End

Terminator

Use once at the beginning and once at the end. Label these Start and End.

total ← total + mark

Process

Use for calculations, assignments and actions the program performs.

INPUT mark

Input / Output

Use when the program receives data or displays information to the user.

mark >= 50?

Decision

Use a question with two labelled exits, normally Yes and No.

flow line

Flow Line

Use arrow direction to show the next step. Every symbol should be connected logically.

A

Connector

Use sparingly to avoid crossed lines or continue a large flowchart on the same page.

Correct Example: Selection

This flowchart checks whether a mark is a pass. Notice the decision diamond is written as a question and both outgoing branches are labelled.

Selection flowchart for checking whether a mark is a pass Start, input mark, decision mark greater than or equal to 50, yes outputs Pass, no outputs Not yet, both branches flow to End. Start INPUT mark mark >= 50? Yes No OUTPUT "Pass" OUTPUT "Not yet" End

Correct Example: Iteration

A loop must show the path that repeats. This example keeps asking for a password until it is correct or the user has tried three times.

Iteration flowchart for password attempts Start, set attempts to zero, input password, check whether password is correct. If yes, output Access granted and end. If no, increment attempts and check whether attempts is less than three. If yes, loop back to input password. If no, output Account locked and end. Start attempts ← 0 INPUT password password correct? Yes OUTPUT "Access granted" No attempts ← attempts + 1 attempts < 3? Yes No OUTPUT "Account locked" End

Accuracy Checklist

Do

  • Use a terminator for Start and End.
  • Use parallelograms only for INPUT and OUTPUT.
  • Write decision diamonds as questions.
  • Label decision branches, usually Yes and No.
  • Show the loop-back arrow when a step repeats.

Don't

  • Put calculations inside input/output symbols.
  • Leave decision arrows unlabelled.
  • Let arrows float without touching symbols.
  • Use a decision diamond for an action such as calculating a total.
  • Draw a loop as a straight line with no return path.

Pseudocode

A plain-language description of code logic. Not a real programming language.

Conventions

  • Use ← for assignment (not =)
  • Keywords in UPPERCASE: IF, THEN, ELSE, FOR, WHILE, ENDFOR, etc.
  • Indent to show structure
  • Use meaningful variable names

Example: Calculate Average

BEGIN CalculateAverage
    total ← 0
    count ← 0

    INPUT number
    WHILE number ≠ -1
        total ← total + number
        count ← count + 1
        INPUT number
    ENDWHILE

    IF count > 0 THEN
        average ← total / count
        OUTPUT "Average is: " + average
    ELSE
        OUTPUT "No numbers entered"
    ENDIF
END CalculateAverage