Lecture 2 Pseudocode Flowcharts
Lecture 2 Pseudocode Flowcharts
BEE4D
Samin Khaliq
Lecture 2: Outline
Pseudocode
Flowcharts
Problem Solving and
Implementation
A typical programming task can be divided
into two phases:
Problem solving phase
Produce an ordered sequence of steps that describe
solution of problem
This sequence of steps is called an algorithm
Implementation phase
Implement the program in some programming
language
Developing a program
Problem solving
phase
Implementation
phase
Definitions
Pseudocode
Informal high level description of computer
instructions written in ordinary natural
language (e.g., English, French, German, etc.).
Flowchart
Diagrammatic representation of steps for
solving the given problem.
Program
A precise sequence of steps to solve a
particular problem.
Problem 1
Problem
Calculate the area of a rectangle.
Pseudocode
INPUT: height of rectangle, width of rectangle
PRINT area = height times width
Problem 2
Input: Temp
if Temp < 32 then
Print BELOW FREEZING
else
Print ABOVE FREEZING
end
Problem 3
Pseudocode:
count assigned 1
while count < 10
{
Print count
Increment count
}
Basic Logic Structures
1. Sequence
2. Selection (IF...THEN...ELSE or
IF....THEN)
Pseudo Code
IF Tea
Then Pour a cup of
Tea
Else Pour a cup of
Coffee
Example
Exercise
IF N < 0 THEN
WRITE "Negative number"
ELSE
WRITE "Positive number"
ENDIF
END
Flowchart
Derived Structure: Case
Check
Process
Condition
DO WHILE Structure
Process
Check
Condition
Difference between WHILE & DO
WHILE
Figure a Figure b
Convert the
flowchart
shown in figure
into
pseudocode
for finding the
largest of three
numbers.
Class Exercise
Write pseudocode and draw a flowchart to
a) read an employee name (NAME), overtime
hours worked (OVERTIME), hours absent
(ABSENT) and
b) determine the bonus payment (PAYMENT).
Bonus Schedule
OVERTIME (2/3)*ABSENT Bonus Paid
Pseudocode
MS Word 2010
Flowcharts
Visual Logic 2.2.4
Microsoft Visio 2010
Summary
Given problem
Pseudocode
Flowcharts