0% found this document useful (0 votes)
72 views

Design

Flowcharts and pseudocode are used to design and represent algorithms. Pseudocode uses language-like structures to show the steps of an algorithm without being an actual programming language. Common pseudocode statements include input, output, decision making like if/then, and repetition like while loops. Flowcharts use graphical elements like boxes, arrows and labels to visually depict the flow of an algorithm. Both are effective tools for planning algorithms before implementing in an actual programming language.

Uploaded by

Nnalue Favour
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views

Design

Flowcharts and pseudocode are used to design and represent algorithms. Pseudocode uses language-like structures to show the steps of an algorithm without being an actual programming language. Common pseudocode statements include input, output, decision making like if/then, and repetition like while loops. Flowcharts use graphical elements like boxes, arrows and labels to visually depict the flow of an algorithm. Both are effective tools for planning algorithms before implementing in an actual programming language.

Uploaded by

Nnalue Favour
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 10

Designing Software With Flowcharts And Pseudo-

code
A Model For Creating Computer Software
Specify the problem

Develop a design (algorithm)

Implement the design

Maintain the design

What Is An Algorithm?
The steps needed to solve a problem

Characteristics

•0 Specific

•1 Unambiguous

•2 Language independent

Developing An Algorithm: Top-Down Approach

Techniques For Laying Out An Algorithm


Pseudo-code

Flowcharts

Pseudo-Code
Employs 'programming-like' statements to depict the algorithm

No standard format (language independent)


Pseudo-Code Statements
Output

Input

Process

Decision

Repetition

Variables
Are symbols used to store values

The value stored can change during the algorithm

Output
Used to display information

General format:
Line of text: Output 'Message'

Variable: Output Name of variable

Example
Output 'Available credit limit: ' limit

Input
Used to get information

Information is stored in a variable


General format:

Input: Name of variable

Example:
Input user_name

Pseudo-Code: Process
For computer programs it's usually an assignment statement (sets a variable to some
value)

General form:

variable arithmetic expression

Example:
x 2

x x+1

a b*c

Pseudo-Code: Decision Making


If-then

General form:

if (condition is met) then

statement(s)

Example:

if temperature < 0 then

wear a jacket
If-then-else

General form:

if (condition is met) then

statement(s)

else

statements(s)

Pseudo-Code: Decision Making (2)

Example:

if (at work) then

Dress formally

else

Dress casually

Pseudo-Code: Repetition
repeat-until

while-do

Pseudo-Code: Repetition (2)


repeat-until

Repeat at least once (check condition after statement(s))


General form:

repeat

statement(s)

until (condition is met)

Example:

repeat

Go up to buffet table

until full

Pseudo-Code: Repetition (3)


while-do

Repeat zero or more times (check condition before statement(s))

General form:

while (condition is met)

statement(s)

Example:

while students ask questions


Answer questions

Pseudo-Code: Fast Food Example


Use pseudo-code to specify the algorithm for a person who ordering food at a fast food restaurant. At the
food counter, the person can either order not order the following items: a burger, fries and a drink. After
placing her order the person then goes to the cashier.

Pseudo-Code: Fast Food Example


Approach counter

if want burger then

order burger

if want fries then

order fries

if want drink then

order drink

Pay cashier

Pseudo-Code: Fast Food Example (Computer)


Approach counter

Output 'Order burger?'

Input order_burger

if order_burger = yes then

order_burger

Output 'Order fries?'


Input order_fries

if order_fries = yes then

order fries

Pseudo-Code: Fast Food Example (Computer 2)


Output 'Order drink?'

Input order_drink

If order_drink = yes then

order drink

Pay cashier

Pseudo-Code: ATM Example


Use pseudo-code to specify the algorithm for an ATM bank machine. The bank machine has four options:
1) Show current balance 2) Deposit money 3) Withdraw money 4) Quit. After an option has been selected,
the ATM will continue displaying the four options to the person until he selects the option to quit the ATM.

Pseudo-Code: ATM Example


Approach ATM

Repeat

Output 'Select option'

Output '1) Make withdrawal'

Output '2) Make deposit'

Output '3) Show balance'

Output '4) Quit'

Input option
Pseudo-Code: ATM Example (2)
If option = deposit then

Output 'Enter amount to deposit'

Input amount

balance balance + amount

If option = withdrawal then

Output 'Enter amount to withdraw'

Input amount

balance balance – amount

Output 'Balance is ' balance

Until option = quit

Stop

Summary Of Pseudo-Code Statements


Statement Purpose

Output Display information

Input Get information

Process Perform an atomic (non-divisible) activity

Decision Choose between different alternatives

Repetition Perform a step multiple times


Basic Flowcharts Element

Flowchart: Fast Food Example


Draw a flowchart to outline the algorithm for a person who ordering food at a fast food restaurant. At the
food counter, the person can either order not order the following items: a burger, fries and a drink. After
placing her order the person then goes to the cashier.

Flowchart: Fast Food Example

Flowchart: Fast Food Example (Computer)

Flowchart: Fast Food Example (Computer 2)

Flowchart: Fast Food Example (Computer 3)

Flowchart: ATM Example


Draw a flowchart to outline the algorithm for an ATM bank machine. The bank machine has four options:
1) Show current balance 2) Deposit money 3) Withdraw money 4) Quit. After an option has been selected,
the ATM will continue displaying the four options to the person until he selects the option to quit the ATM.

Flowchart: ATM Example

Flowchart: ATM Example (2)

Flowchart: ATM Example (3)

Flowchart: ATM Example (4)

Summary
Laying out an algorithm using flowcharts and pseudo-code

Learning basic elements of algorithms:


•3 Input

•4 Output
•5 Decision-Making

•6 Repetition

•7 Processes

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy