Flowcharts Pseudocode
Flowchart Symbols
Different flowchart shapes have different conventional meanings. The meanings of some of the more
common shapes are as follows:
Terminator
The terminator symbol represents the starting or ending point of the system.
Process
A box indicates some particular operation.
Decision
A diamond represents a decision or branching point. Lines coming out from the diamond indicates
different possible situations, leading to different sub-processes.
Data
It represents information entering or leaving the system. An input might be an order from a customer.
Output can be a product to be delivered.
Flow
Lines represent the flow of the sequence and direction of a process.
Flowchart examples
Flowchart Example – Calculate sum of two numbers
Flowchart Example – Calculate Profit and Loss
The flowchart example below shows how profit and loss can be calculated.
PseudocodeReference Guide and Examples
CATEGORY Instruction Syntax EXAMPLE
Input READ READ variable READ num1
Output DISPLAY DISPLAY variable DISPLAY num1
Initialization SET SET variable TO value SET total TO 0
Computation COMPUTE COMPUTE variable AS
arithmetic expression
COMPUTE sum AS num1 +
num2
Increment/Decrement ADD
SUBTRACT
ADD value TO variable
SUBTRACT value FROM
variable
ADD 1 TO num1
SUBTRACT 1 FROM num1
Branching/Decisions IF-THEN IF Boolean condition THEN
instruction if true
ENDIF
IF x < 5 THEN DISPLAY “SMALL NUMBER” ENDIF
IF-THEN-ELSE IF Boolean condition THEN
instruction if true
ELSE
Instruction if false
ENDIF
IF temp > 90 THEN
DISPLAY “HOT”
ELSE
DISPLAY “NOT SO HOT!”
ENDIF
OPERATORS + – * / AND OR NOT < <= > >= == !=
Examples:
1. Add two numbers
READ num1
READ num2
COMPUTE sum AS num1 + num2
DISPLAY sum
2. Find the largest of three numbers
READ num1
READ num2
READ num3
IF num1 >= num2 AND num1 >= num3 THEN
DISPLAY num1
ELSE
IF num2 >= num1 AND num2 >= num3 THEN
DISPLAY num2
ELSE
DISPLAY num3
ENDIF
ENDIF
3. Change Fahrenheit temps to Celsius
READ fDegrees
COMPUTE cDegrees AS (fDegrees − 32) × 5/9
DISPLAY cDegrees
4. Determine total pay for work
READ hoursWorked
READ payPerHour
IF hoursWOrked <=0 OR payPerHour <= 0 THEN
DISPLAY “error”
ELSE
COMPUTE totalPay AS hoursWorked * payPerHour
DISPLAY totalPay
ENDIF
5. Calculate and display area of Circle
READ radius
IF radius < = 0 THEN
DISPLAY “error”
ELSE
CALCULATE area AS radius * radius * 3.14
DISPLAY area
ENDIF