Pseudocode: An Introduction
Pseudocode: An Introduction
Pseudocode: An Introduction
An Introduction
Flowcharts were the first design tool to be
widely used, but unfortunately they do not
reflect some of the concepts of structured
programming very well. Pseudocode, on the
other hand, is a newer tool and has features
that make it more reflective of the structured
concepts. The drawback is that the narrative
presentation is not as easy to understand
and/or follow.
Rules for Pseudocode
Task List
Read name, hours worked, rate of pay Pseudocode
Perform calculations READ name, hoursWorked, payRate
Pseudocode
READ name, hoursWorked, payRate
gross = hoursWorked * payRate
WRITE name, hoursWorked, gross
Indent to Show Hierarchy
Each design structure uses a particular indentation
pattern
• Sequence:
Keep statements in sequence all starting in the same column
• Selection:
Indent statements that fall inside selection structure, but not the keywords that form the
selection
• Loop:
Indent statements that fall inside the loop but not keywords that form the loop
yes no
amount < 100
WHILE/ENDWHILE
REPEAT/UNTIL
WHILE / ENDWHILE
Start count = 0
WHILE count < 10
ADD 1 to count
count = 0
WRITE count
ENDWHILE
WRITE “The End”
no
count
Mainline
<10
Modular
yes count = 0
Write
“The End”
WHILE count < 10
add 1 to
count DO Process
ENDWHILE
Stop
write count WRITE “The End”
Process
ADD 1 to count
WRITE count
REPEAT / UNTIL
Start count = 0
REPEAT
count = 0
ADD 1 to count
WRITE count
UNTIL count >= 10
add 1 to WRITE “The End”
count
Mainline
Modular
write count count = 0
REPEAT
yes DO Process
count
<10 UNTIL count >= 10
no WRITE “The End”
Write Process
“The End”
ADD 1 to count
Stop WRITE count
Advantages & Disadvantages
Flowchart Advantages: Pseudocode Advantages
Standardized Easily modified
Visual Implements structured concepts
Done easily on Word Processor