An algorithm must be written down before it can be checked, discussed or translated into a program. Two notations are in common use: pseudocode, which uses structured English, and the flowchart, which uses a diagram.

Algorithm: Definition and Characteristics

An algorithm is a finite sequence of clear steps that solves a problem. As studied in Unit I, every algorithm has five characteristics: it accepts input, produces output, is definite (each step has one meaning), is finite (it stops), and is effective (each step can actually be carried out).

Standard Format of an Algorithm

A well-presented algorithm has a fixed layout: a name, a statement of its inputs and outputs, and numbered steps beginning with Start and ending with Stop.

Algorithm: Larger of two numbers
Input:  two numbers A and B
Output: the larger of A and B
Step 1: Start
Step 2: Read A, B
Step 3: If A > B then go to Step 4, otherwise go to Step 5
Step 4: Display A and go to Step 6
Step 5: Display B
Step 6: Stop

Pseudocode

Definition: Pseudocode. A way of describing the steps of an algorithm in structured, language-independent English, using indentation to show sequence, selection and repetition.

Pseudocode is not bound by the grammar of any programming language, but it uses a small set of keywords consistently, such as READ, DISPLAY, IF, ELSE, WHILE and FOR. Indentation shows which statements belong to which structure.

BEGIN
    READ A, B
    IF A > B THEN
        DISPLAY A
    ELSE
        DISPLAY B
    ENDIF
END

Flowcharts

Definition: Flowchart. A diagram that represents an algorithm using standard symbols joined by arrows that show the order of the steps.

Each symbol has a fixed meaning, given in Table 2.5.

Table 2.5: Standard flowchart symbols

Symbol Name Purpose
Oval Terminal Marks Start and Stop
Parallelogram Input/Output Reads data or displays results
Rectangle Process Calculation or assignment
Diamond Decision A condition with two outgoing branches
Arrow Flow line Shows the order of the steps
Small circle Connector Joins parts of a flowchart

Rules for Drawing a Flowchart

  • A flowchart has exactly one Start and one Stop.
  • Flow generally runs from top to bottom and from left to right.
  • Every decision symbol has two labelled exits, such as yes and no.
  • Flow lines should not cross; connectors are used where needed.
  • Each symbol contains a short, clear statement.

Choosing a Notation

A flowchart shows the flow of control at a glance and suits small algorithms and explanations. Pseudocode is compact, easy to modify and close to program code, so it suits larger algorithms. In practice the two are used together.

Example 2.5: Algorithm in both notations

Problem: Write pseudocode to decide whether a number N is even or odd, and state how the flowchart would differ.

Solution:

  1. The input is N. The output is the word "Even" or "Odd".
  2. A number is even when the remainder on division by 2 is 0.
BEGIN
    READ N
    IF N MOD 2 = 0 THEN
        DISPLAY "Even"
    ELSE
        DISPLAY "Odd"
    ENDIF
END
  1. In a flowchart, READ N becomes a parallelogram, the test N MOD 2 = 0 becomes a diamond with yes and no branches, and each DISPLAY becomes a parallelogram. Ovals mark Start and Stop.

Result: For N = 7, the remainder is 1, the condition is false and the output is "Odd".

Common mistakes

  • Using a rectangle for input or output, or a parallelogram for a calculation.
  • Leaving the branches of a decision symbol unlabelled.
  • Writing pseudocode in the exact syntax of C, which defeats its purpose of being language-independent.

Key takeaways

  • The standard algorithm format gives a name, inputs, outputs and numbered steps from Start to Stop.
  • Pseudocode uses structured English and indentation.
  • A flowchart uses ovals, parallelograms, rectangles, diamonds and arrows.
  • Every decision has exactly two labelled exits.

Practice questions

  1. Which flowchart symbol represents a decision?
  2. Which symbol is used for both reading input and displaying output?
  3. State one advantage of pseudocode over a flowchart.

Answers to the practice questions

  1. The diamond.
  2. The parallelogram.
  3. It is compact and easy to modify, and it is close to program code, which suits larger algorithms.

Sources

  • Official BCA syllabus (NEP 2025 scheme), Problem Solving Techniques, course code 25BCA401SEC01, Unit II