Design
Design
code
A Model For Creating Computer Software
Specify the problem
What Is An Algorithm?
The steps needed to solve a problem
Characteristics
•0 Specific
•1 Unambiguous
•2 Language independent
Flowcharts
Pseudo-Code
Employs 'programming-like' statements to depict the algorithm
Input
Process
Decision
Repetition
Variables
Are symbols used to store values
Output
Used to display information
General format:
Line of text: Output 'Message'
Example
Output 'Available credit limit: ' limit
Input
Used to get information
Example:
Input user_name
Pseudo-Code: Process
For computer programs it's usually an assignment statement (sets a variable to some
value)
General form:
Example:
x 2
x x+1
a b*c
General form:
statement(s)
Example:
wear a jacket
If-then-else
General form:
statement(s)
else
statements(s)
Example:
Dress formally
else
Dress casually
Pseudo-Code: Repetition
repeat-until
while-do
repeat
statement(s)
Example:
repeat
Go up to buffet table
until full
General form:
statement(s)
Example:
order burger
order fries
order drink
Pay cashier
Input order_burger
order_burger
order fries
Input order_drink
order drink
Pay cashier
Repeat
Input option
Pseudo-Code: ATM Example (2)
If option = deposit then
Input amount
Input amount
Stop
Summary
Laying out an algorithm using flowcharts and pseudo-code
•4 Output
•5 Decision-Making
•6 Repetition
•7 Processes