F

11.1 Flowchart & Structured English

Understanding, drawing, and interpreting program flowcharts for algorithms and decision-making processes

Learning Objectives

By the end of this lesson, you will be able to:

  • Draw basic program flowcharts that demonstrate decision-making processes
  • Edit and modify given flowcharts to correct errors or improve logic
  • Design flowcharts to solve specific computational problems
  • Identify and correctly use flowchart symbols: input/output, decision, terminator, process boxes, subroutine, connector, and flow lines
  • Identify errors in algorithms and program flowcharts for given scenarios
  • Create trace tables to follow flowchart execution with test data
  • Convert between pseudocode, algorithms, and flowchart representations
  • Implement and write Cambridge-style pseudocode from given flowcharts or structured English
  • Write pseudocode statements for declaring variables and constants, assignments, expressions, and input/output operations

Key Terms

Flowchart

A diagrammatic way of representing an algorithm used to produce the solution to a problem

Terminator

Symbol used to show where a flowchart begins (START) and where it ends (STOP)

Process Box

Rectangle symbol representing any calculation or variable assignment (uses ← symbol)

Input/Output

Parallelogram shape representing input or output operations (equivalent to INPUT or PRINT)

Decision Box

Diamond shape representing conditional statements (IF) or loops, with Yes/True and No/False branches

Subroutine

Symbol used to call a subroutine from the main flowchart (equivalent to CALL statement)

Flow Line

Arrow lines showing the direction to follow when working through a flowchart

Connector

Circle symbol indicating continuation of a flowchart across multiple pages

Algorithm

A step-by-step procedure or formula for solving a problem

Trace Table

A table used to track variable values and outputs as an algorithm executes step by step

Sequence

The simplest programming construct where instructions are executed one after another

Test Data

Data used to test a program, including normal, abnormal/erroneous, and boundary/extreme cases

Pseudocode

A simplified programming language used to design algorithms, following Cambridge conventions

Structured English

A restricted subset of English used to describe algorithms in a clear, unambiguous way

Flowchart Fundamentals

A program flowchart is a diagrammatic way of representing an algorithm used to produce the solution to a problem. Flowcharts help visualize the logic and flow of a program before writing actual code.

Flowchart Symbols

Standard Flowchart Symbols

START
Terminator
Start/Stop
Process
Process Box
Calculations
INPUT X
Input/Output
Parallelogram
X > 10?
Decision
Diamond
CALL Calc
Subroutine
Call function
A
Connector
Continuation
Symbol Details:
  • Terminator: Oval shape showing where flowchart begins and ends
  • Process Box: Rectangle representing calculations or variable assignments (uses ← symbol)
  • Input/Output: Parallelogram equivalent to INPUT or PRINT statements
  • Decision Box: Diamond shape with Yes/True and No/False branches
  • Subroutine: Symbol used to call a subroutine (equivalent to CALL)
  • Flow Line: Arrows showing direction through the flowchart
  • Connector: Circle indicating flowchart continuation across pages
Real-Life Analogy:

Think of a flowchart like a recipe for cooking:

  • Terminator: "Start cooking" and "Serve meal"
  • Process Box: "Chop vegetables", "Mix ingredients"
  • Input/Output: "Add 2 cups of flour", "Taste the sauce"
  • Decision Box: "Is the pasta cooked?" → Yes/No branches
  • Subroutine: "Make the sauce" (a separate procedure)
  • Flow Lines: The order of steps in the recipe

Flowchart Symbols Interactive Guide

Drag and drop flowchart symbols to build a simple algorithm. This simulation helps you understand how different symbols connect to form a complete flowchart.

START
Terminator
INPUT
Input/Output
PROCESS
Process
DECISION
Decision
CALL
Subroutine
Drag symbols here to build your flowchart

How to use: Drag symbols from the palette to the canvas. Connect them in logical order to create algorithms like "Check if a number is positive" or "Calculate average of three numbers".

Example: Weather Decision Flowchart

Flowchart Description:
  1. START
  2. Check the Weather Channel
  3. Decision: Rain Predicted? (Yes/No)
  4. If Yes: Stay Home
  5. If No: Play Golf
  6. STOP
Note:

This is a simple sequence with one decision point. The Weather Channel is a Cable Channel.

START
Check the Weather Channel
(Cable Channel 61)
Rain Predicted?
Yes → Stay Home No → Play Golf
STOP

Real-Life Example: Mobile App Login Flowchart

Most mobile apps use flowcharts to design their user experience. Here's a simplified login process:

START Login Process
User opens app
INPUT username, password
User enters credentials
DECISION: Valid credentials?
Yes → Go to main screen
No → Show error message
DECISION: Remember me checked?
Yes → Save login token
No → Don't save
STOP Login Process

This flowchart helps developers visualize the login process before writing code, ensuring all cases (valid/invalid credentials, remember me option) are handled.

Check Your Understanding: Flowchart Fundamentals

Answer
  • [1 mark] Diamond shape
  • [Additional] The diamond has two arrows coming out: one for Yes/True and one for No/False
Answer
  • [1 mark] To show where the flowchart begins (START)
  • [1 mark] To show where the flowchart ends (STOP)
  • [Additional] Usually oval-shaped, marks entry and exit points of the algorithm
Answer
  • [1 mark] Parallelogram shape
  • [Additional] Equivalent to INPUT or PRINT statements in pseudocode
Answer
  • [1 mark] When a flowchart extends over multiple pages
  • [1 mark] To indicate continuation points between pages
  • [Additional] Usually a circle with a letter or number inside to match corresponding connectors
Answer
  • [1 mark] Process box: Rectangle used for calculations and variable assignments (uses ←)
  • [1 mark] Input/Output: Parallelogram used for reading input or displaying output
  • [Additional] Example: "X ← Y + Z" goes in process box, "INPUT name" goes in input/output symbol

Drawing and Interpreting Flowcharts

Flowcharts visually represent algorithms. Being able to draw and interpret them is essential for designing, understanding, and debugging programs.

Example: Profit/Loss Calculation

Problem Description:

Read Cost Price (CP) and Selling Price (SP). Determine if there's a profit or loss.

Algorithm Steps:
  1. Read CP
  2. Read SP
  3. If SP > CP then Profit = SP - CP
  4. Otherwise Loss = CP - SP
  5. End
Trace Example:

When CP = 325 and SP = 458:

  • Condition: Is 458 > 325? → Yes
  • Profit = 458 - 325 = 133
  • Result: Profit = Rs. 133
START
Read Cost price (CP)
Input operation
Read Selling price (SP)
Input operation
Is SP > CP?
Yes No
Profit = SP - CP
Process
Loss = CP - SP
Process
END

Activity 1: Trace Table Practice

Complete the trace table for the following flowchart using test data: 9, 7, 3, 12, 6, 4, 15, 2, 8, 5

A B C X Output
0 0 100
1 9 9
2 7 7
3 3 3
4 12 12
5 6
6 4
7 15 15
8 2 2
9 8
10 5
15

Flowchart Logic:

Start with A=0, B=0, C=100
Repeat until A >= 10:
  Input X
  If X > B then B = X
  If X < C then C = X
  A = A + 1
Output B, C
Solution:
A B C X Output
0 0 100
1 9 9 9
2 9 7 7
3 9 3 3
4 12 3 12
5 12 3 6
6 12 3 4
7 15 3 15
8 15 2 2
9 15 2 8
10 15 2 5
15, 2

Explanation: The algorithm finds the maximum (B) and minimum (C) values from 10 inputs. B tracks the highest value seen, C tracks the lowest. Final output is B=15, C=2.

Flowchart with Subroutine

Pseudocode:
INPUT width, height
// type in the height and width of the triangle
CALL triangle (width, height)
// this would print out the area
INPUT number
// type in the number of walls
count ← 0
WHILE count < number
    INPUT length, height
    count ← count + 1
    CALL rectangle (length, height)
ENDWHILE
What this algorithm does:
  • Calculates area of one triangle using subroutine
  • Then calculates areas of multiple rectangles using a loop
  • Uses a WHILE loop with counter (count)
  • Demonstrates subroutine calls within a flowchart
START
INPUT width, height
CALL triangle(width, height)
Subroutine
INPUT number
count ← 0
count < number?
Yes No → STOP
INPUT length, height
count ← count + 1
CALL rectangle(length, height)
Subroutine

Activity 2: Draw a Flowchart

Draw a flowchart to add up five numbers.

Pseudocode provided:
Declare Num, total, count : Integer
Count ← 0
Total ← 0
While count < 5 Do
    Count ← Count + 1
    Total ← Total + Num
Endwhile
Output "Sum of 5 numbers is " Total

Note: There's an error in the pseudocode - it should INPUT Num inside the loop!

Draw the correct flowchart that:

  1. Initializes count and total to 0
  2. Uses a loop to input 5 numbers
  3. Adds each number to the total
  4. Outputs the final sum
Solution Flowchart:
START
count ← 0
total ← 0
count < 5?
Yes No
INPUT number
Get next number
total ← total + number
Add to sum
count ← count + 1
Increment counter
PRINT total
Output result
STOP

Key points: The loop continues while count < 5 (0-4 = 5 iterations). We INPUT a number inside the loop, add it to total, then increment count. The pseudocode is missing the INPUT statement inside the loop.

Real-Life Example: Online Shopping Checkout Flowchart

Most e-commerce websites use complex flowcharts to design their checkout process:

START Checkout
User clicks checkout button
DECISION: User logged in?
No → CALL Login_Process()
Yes → Continue
INPUT shipping address
DECISION: Address valid?
No → Show error, retry
Yes → Continue
INPUT payment details
CALL Process_Payment()
DECISION: Payment successful?
No → Show error, retry
Yes → Generate order confirmation
STOP Checkout

This flowchart ensures all cases are handled: user authentication, address validation, payment processing, and error handling.

Check Your Understanding: Drawing & Interpreting

Answer
  • [1 mark] Finds the maximum value (stored in B) from 10 inputs
  • [1 mark] Finds the minimum value (stored in C) from 10 inputs
  • [Additional] B starts at 0, C starts at 100. After processing 10 numbers, B contains the highest, C contains the lowest.
Answer
  • [1 mark] There is no INPUT statement to read the numbers
  • [1 mark] The variable "Num" is used in the calculation but never assigned a value
  • [Additional] Corrected version should have "INPUT Num" inside the while loop before adding to total
Answer
  • [1 mark] The loop executes "number" times
  • [1 mark] Count starts at 0, increments by 1 each time, loop continues while count < number
  • [Additional] If number=5: count=0,1,2,3,4 (5 iterations). When count=5, condition fails, loop stops.
Answer
  • [1 mark] Condition: Is SP > CP? 150 > 200? → No
  • [1 mark] Loss = CP - SP = 200 - 150 = 50
  • [Additional] Since selling price (150) is less than cost price (200), there's a loss of 50.
Answer
  • [1 mark] Normal test data
  • [1 mark] Abnormal / erroneous / invalid test data
  • [1 mark] Boundary / extreme test data
  • [Additional] 5: "A programmer can use three types of test data when testing a program"

Exam-Style Flowchart Questions

Exam questions often ask you to draw flowcharts based on algorithm descriptions or identify errors in given flowcharts.

Example: Prime Number Counter

Algorithm Description:
  1. Input an integer value.
  2. Jump to step 6 if the value is less than zero.
  3. Call the function IsPrime() using the integer value as a parameter.
  4. Keep a count of the number of times function IsPrime() returns TRUE.
  5. Repeat from step 1.
  6. Output the value of the count with a suitable message.
What this algorithm does:
  • Continuously reads integers until a negative number is entered
  • For each non-negative number, checks if it's prime using IsPrime() function
  • Counts how many prime numbers were entered
  • When a negative number is entered, stops and outputs the count
  • Uses a sentinel value (negative number) to terminate input
START
Set Count to 0
Initialize counter
INPUT NextNum
Get number from user
Is NextNum < 0?
Yes No
Set Answer to IsPrime(NextNum)
Call subroutine
Is Answer = TRUE?
Yes No
Set Count to Count + 1
Increment if prime
OUTPUT "Answer is" & Count
Final output
END

Common Flowchart Errors to Avoid

Structural Errors:
  • Missing terminators - No START or STOP symbols
  • Incorrect symbol shapes - Using rectangle for decision or parallelogram for process
  • Unconnected flow lines - Gaps between symbols
  • Crossing flow lines - Makes the flowchart hard to follow
  • Missing decision branches - Only showing Yes or No path, not both
Logic Errors:
  • Infinite loops - No way to exit the loop
  • Incorrect loop conditions - Wrong comparison or counter update
  • Missing initialization - Variables not set before use
  • Wrong order of operations - Processing before input or vice versa
  • Off-by-one errors - Looping one time too many or too few
Exam Tip: How to Check Your Flowchart
  1. Trace with sample data - Walk through with simple test values
  2. Check all paths - Ensure every Yes/No branch leads somewhere valid
  3. Verify loop exit - Make sure loops can terminate
  4. Test boundary cases - What happens with minimum/maximum values?
  5. Use correct symbols - Examiners check symbol shapes carefully

Exam Question Practice

Exam-Style Question: A school library system needs a flowchart for checking out books. The process is:

Algorithm:
  1. Start
  2. Input StudentID and BookID
  3. Check if StudentID is valid (call ValidateStudent subroutine)
  4. If invalid, output "Invalid Student ID" and stop
  5. Check if BookID is available (call CheckAvailability subroutine)
  6. If not available, output "Book not available" and stop
  7. Update records (call UpdateRecords subroutine)
  8. Output "Book checked out successfully"
  9. Stop

Draw a flowchart for this library checkout system. Include all symbols: terminators, input/output, decisions, process boxes, and subroutines.

Solution Flowchart:
START
INPUT StudentID, BookID
CALL ValidateStudent(StudentID)
Subroutine
Valid Student?
No Yes
OUTPUT "Invalid Student ID"
Error message
CALL CheckAvailability(BookID)
Subroutine
Book Available?
No Yes
OUTPUT "Book not available"
Error message
CALL UpdateRecords()
Subroutine
OUTPUT "Book checked out successfully"
STOP

Key features: Uses three subroutines (ValidateStudent, CheckAvailability, UpdateRecords). Has two decision points with error handling. Shows both successful and unsuccessful paths. All symbols are correctly shaped.

Converting Between Flowcharts and Pseudocode

Flowchart Symbol → Pseudocode
Flowchart Symbol Pseudocode Equivalent
Terminator (START/STOP) Beginning/end of algorithm
Input/Output (Parallelogram) INPUT or OUTPUT/PRINT statements
Process Box (Rectangle) Assignment statements (variable ← value)
Decision (Diamond) IF...THEN...ELSE or WHILE conditions
Subroutine CALL statement
Flow Lines Sequence of execution
Example Conversion:
// Flowchart: Add two numbers
START
INPUT num1
INPUT num2
sum ← num1 + num2
OUTPUT sum
STOP
// Pseudocode equivalent:
INPUT num1
INPUT num2
sum ← num1 + num2
OUTPUT sum

Check Your Understanding: Exam Preparation

Answer
  • [1 mark] When a negative number is input
  • [1 mark] The negative number acts as a sentinel value to terminate input
  • [Additional] The algorithm says: "Jump to step 6 if the value is less than zero"
Answer
  • [1 mark] Count-controlled loop (WHILE loop with counter)
  • [Additional] The loop executes exactly 5 times, controlled by "count < 5" condition
Answer
  • [1 mark] Ensures variables start with known values before use
  • [1 mark] Prevents errors from uninitialized variables (garbage values)
  • [Additional] Example: In "Add five numbers", total must start at 0 before adding numbers
Answer
  • [1 mark] Change decision from "SP > CP" to "SP >= CP"
  • [1 mark] Or add another decision: If SP = CP then output "No profit, no loss"
  • [Additional] Current flowchart treats SP = CP as loss (since SP > CP is false), which is incorrect
Answer
  • [1 mark] To track variable values as an algorithm executes step by step
  • [1 mark] To verify algorithm correctness and identify logic errors
  • [Additional] Used for debugging and understanding how algorithms work with specific test data

Cambridge Pseudocode Implementation

Cambridge pseudocode is a standardized way to represent algorithms using a structured, programming-like syntax that follows Cambridge International conventions. It bridges the gap between flowcharts/structured English and actual programming code.

Cambridge Pseudocode Syntax Rules

1. Declaration and Initialization
// Constants (values that don't change)
CONSTANT MaxScore = 100
CONSTANT Pi = 3.14159
// Variables (values that can change)
DECLARE score : INTEGER
DECLARE name : STRING
DECLARE price : REAL
DECLARE isPassed : BOOLEAN
// Combined declaration and initialization
DECLARE counter : INTEGER 0
DECLARE total : REAL 0.0
2. Assignment Statements
// Basic assignment using ←
counter 1
total price * quantity
average sum / count
isValid TRUE
// Increment/Decrement
counter counter + 1
score score - 5
3. Expressions with Operators
// Arithmetic operators
sum a + b
difference x - y
product num1 * num2
quotient numerator / denominator
remainder number MOD 2
// Logical operators (AND, OR, NOT)
isPass (score > = 50) AND (attendance >= 75)
canProceed (age > = 18) OR (parentApproval = TRUE)
isInvalid NOT (isValid)
// Comparison operators
isGreater a > b
isEqual x = y
isNotEqual value ! = 0
4. Input and Output Statements
// Input from keyboard
INPUT username
INPUT age
INPUT score1, score2, score3
// Output to console
OUTPUT "Hello, World!"
OUTPUT "Your score is: ", score
PRINT "Average = ", average
// Example: Complete program
DECLARE radius, area : REAL
CONSTANT Pi = 3.14159
INPUT radius
area Pi * radius * radius
OUTPUT "Area of circle = ", area

Structured English for Algorithm Design

What is Structured English?

Structured English is a restricted subset of English used to describe algorithms in a clear, unambiguous way. It uses:

  • Imperative verbs (Read, Write, Calculate, If, While, Repeat)
  • Clear, simple sentences
  • Indentation to show structure
  • Standardized keywords
Example: Structured English for Finding Maximum
1. Start
2. Read three numbers: num1, num2, num3
3. Set max to num1
4. If num2 > max then set max to num2
5. If num3 > max then set max to num3
6. Output "Maximum is: " followed by max
7. End
Converting to Cambridge Pseudocode
// Converted from Structured English
DECLARE num1, num2, num3, max : INTEGER
INPUT num1, num2, num3
max num1
IF num2 > max THEN
    max num2
ENDIF
IF num3 > max THEN
    max num3
ENDIF
OUTPUT "Maximum is: ", max

Practice: Convert Flowchart to Cambridge Pseudocode

Convert this flowchart to Cambridge pseudocode:

START
INPUT age
age >= 18?
Yes No
OUTPUT "Adult"
OUTPUT "Minor"
STOP

Write the complete Cambridge pseudocode including variable declaration, input, decision logic, and output.

Solution:
// Age classification program
DECLARE age : INTEGER
INPUT age
IF age >= 18 THEN
    OUTPUT "Adult"
ELSE
    OUTPUT "Minor"
ENDIF

Marking points: Correct variable declaration [1], proper INPUT statement [1], correct IF condition [1], appropriate OUTPUT statements [1], proper indentation and ENDIF [1].

Practice: Structured English to Pseudocode

Convert this Structured English algorithm to Cambridge pseudocode:

1. Start
2. Read a number
3. If the number is greater than 0
4.     Output "Positive"
5. Else if the number is less than 0
6.     Output "Negative"
7. Else
8.     Output "Zero"
9. End

Write the complete Cambridge pseudocode with proper indentation and syntax.

Solution:
// Number classification program
DECLARE number : INTEGER
INPUT number
IF number > 0 THEN
    OUTPUT "Positive"
ELSEIF number < 0 THEN
    OUTPUT "Negative"
ELSE
    OUTPUT "Zero"
ENDIF

Key features: Uses ELSEIF for multiple conditions, proper indentation for readability, correct comparison operators, and ENDIF to close the conditional block.

Check Your Understanding: Cambridge Pseudocode

Answer
CONSTANT VAT_RATE = 0.2
DECLARE price : REAL
  • [1 mark] Correct constant declaration using CONSTANT keyword
  • [1 mark] Correct variable declaration with REAL type
Answer
totalPrice price + (price * VAT_RATE)
  • [1 mark] Correct use of assignment operator (←)
  • [1 mark] Correct calculation including parentheses for order of operations
Answer
DECLARE mark : INTEGER
INPUT mark
IF mark >= 50 THEN
    OUTPUT "Pass"
ELSE
    OUTPUT "Fail"
ENDIF
  • [1 mark] Correct variable declaration
  • [1 mark] Correct INPUT statement
  • [1 mark] Correct IF condition with comparison operator
  • [1 mark] Proper OUTPUT statements in both branches
Answer
isInRange (number >= 10) AND (number <= 20)
  • [1 mark] Correct use of AND operator
  • [1 mark] Correct comparison operators (>= and <= for inclusive range)
Answer
// Calculate average of three numbers
DECLARE num1, num2, num3, average : REAL
INPUT num1, num2, num3
average (num1 + num2 + num3) / 3
OUTPUT "Average = ", average
  • [1 mark] Correct variable declarations
  • [1 mark] Correct INPUT statement for three values
  • [1 mark] Correct calculation with parentheses
  • [1 mark] Correct OUTPUT statement

Key Takeaways

  • Flowcharts are diagrammatic representations of algorithms using standardized symbols
  • Terminator (oval) shows START and STOP points of the algorithm
  • Process box (rectangle) represents calculations and variable assignments (uses ← symbol)
  • Input/Output (parallelogram) represents INPUT or PRINT operations
  • Decision box (diamond) represents conditional statements with Yes/True and No/False branches
  • Subroutine symbol indicates a call to another procedure or function
  • Flow lines (arrows) show the direction of execution through the flowchart
  • Connector (circle) indicates continuation of a flowchart across multiple pages
  • Trace tables help track variable values and verify algorithm correctness
  • Three types of test data: Normal, Abnormal/Erroneous, and Boundary/Extreme
  • Common errors include missing terminators, incorrect symbols, infinite loops, and uninitialized variables
  • Cambridge pseudocode syntax uses DECLARE for variables, CONSTANT for constants, ← for assignment, and INPUT/OUTPUT for I/O operations
  • Arithmetic operators (+, -, *, /, MOD) and logical operators (AND, OR, NOT) are used in expressions
  • Structured English is a clear, unambiguous way to describe algorithms using imperative verbs
  • Flowcharts, pseudocode, and structured English are interchangeable representations that can be converted between each other
  • Exam questions often require converting between different algorithm representations
  • Real-world applications include login systems, e-commerce checkouts, and mobile app workflows

Question Bank

Marking Scheme & Answer
START
INPUT num1, num2, num3
num1 > num2?
Yes No
max ← num1
max > num3?
Yes No
OUTPUT max
max ← num3
OUTPUT max
max ← num2
max > num3?
Yes No
OUTPUT max
max ← num3
OUTPUT max
STOP

Alternative simpler solution: Compare num1 and num2, store larger in max. Then compare max with num3. If num3 > max, update max. Output max.

Marking Scheme & Answer
  • [1 mark] Decision box missing "No" branch - what happens if X ≤ 10?
  • [1 mark] Output 'Large' should be in output symbol (parallelogram), not decision box
  • [1 mark] Process box (Y←X+5) should be rectangle, not just "Process:"
  • [1 mark] Output Y should be separate output symbol
  • [1 mark] Missing symbols: Need actual flowchart symbols with correct shapes
  • [Additional] Corrected: START → Input X (parallelogram) → X>10? (diamond) → Yes: Output 'Large' (parallelogram) → No: (could go directly to next step) → Y←X+5 (rectangle) → Output Y (parallelogram) → STOP
Marking Scheme & Answer
Iteration number total count average Output
Initial - 0 0 - -
1 5 5 1 - -
2 12 17 2 - -
3 8 25 3 - -
4 -1 25 3 8.33 8.33

Explanation: The algorithm calculates average of positive numbers until a negative is entered. With inputs 5, 12, 8, -1: total = 5+12+8 = 25, count = 3, average = 25/3 ≈ 8.33. The negative number (-1) triggers loop exit but is not added to total.

Marking Scheme & Answer
START
INPUT age
age >= 18?
Yes No
OUTPUT "Adult"
age >= 13?
Yes No
OUTPUT "Teenager"
OUTPUT "Child"
STOP

Key points: Nested IF structure. First checks if adult (≥18). If not, checks if teenager (13-17). If not, must be child (<13). All outputs in parallelogram symbols, decisions in diamonds.

Marking Scheme & Answer
START
INPUT num1, num2, operator
operator = '/'?
Yes No
num2 = 0?
Yes No
OUTPUT "Error: Division by zero"
result ← num1 / num2
OUTPUT result
operator = '+'?
Yes: result ← num1 + num2 No
operator = '-'?
Yes: result ← num1 - num2 No
operator = '*'?
Yes: result ← num1 * num2 No
OUTPUT "Invalid operator"
STOP

Alternative approach: Use CASE structure or nested IFs. Key elements: Check for division by zero before calculating, handle all four operators, provide error messages for invalid operator or division by zero.

Marking Scheme & Answer
  • [1 mark] Connector: Circle symbol used when flowchart continues on another page
  • [1 mark] Subroutine: Rectangle with extra lines (or dashed) representing a call to another procedure
  • [1 mark] Connector connects parts of same flowchart, subroutine calls separate algorithm
  • [Additional] Example: Connector A on page 1 connects to Connector A on page 2. Subroutine CALL triangle(width,height) executes triangle calculation procedure.
Marking Scheme & Answer
  • [1 mark] Visual representation makes algorithms easier to understand
  • [1 mark] Helps identify logic errors before coding
  • [1 mark] Standard symbols provide clear communication between programmers
  • [1 mark] Useful for documentation and explaining program logic to others
  • [Additional] Particularly helpful for complex algorithms with multiple decisions and loops
Marking Scheme & Answer
// Factorial calculation program
DECLARE n, factorial, i : INTEGER
INPUT n
factorial 1
FOR i 1 TO n
    factorial factorial * i
NEXT i
OUTPUT "Factorial of ", n, " is ", factorial

Alternative using WHILE loop:
DECLARE n, factorial, i : INTEGER
INPUT n
factorial ← 1
i ← 1
WHILE i <= n
    factorial ← factorial * i
    i ← i + 1
ENDWHILE
OUTPUT "Factorial of ", n, " is ", factorial

Marking Scheme & Answer
1. Start
2. Input a number n
3. If n is less than 2 then output "Not prime" and end
4. Set divisor to 2
5. Set isPrime to TRUE
6. While divisor is less than n
7.     If n divided by divisor has remainder 0 then
8.         Set isPrime to FALSE
9.     End if
10.     Increment divisor by 1
11. End while
12. If isPrime is TRUE then output "Prime"
13. Else output "Not prime"
14. End

Note: This is basic prime checking. More efficient versions check only up to √n or skip even numbers.

Marking Scheme & Answer
// Simple login system
DECLARE username, password : STRING
DECLARE isValid : BOOLEAN
CONSTANT CORRECT_USERNAME = "admin"
CONSTANT CORRECT_PASSWORD = "password123"
INPUT username, password
isValid (username = CORRECT_USERNAME) AND (password = CORRECT_PASSWORD)
IF isValid = TRUE THEN
    OUTPUT "Access granted"
ELSE
    OUTPUT "Access denied"
ENDIF

Alternative simpler version: Without constants and Boolean variable:
DECLARE username, password : STRING
INPUT username, password
IF username = "admin" AND password = "password123" THEN
    OUTPUT "Access granted"
ELSE
    OUTPUT "Access denied"
ENDIF