Академический Документы
Профессиональный Документы
Культура Документы
Problem Solving
Topic & Structure of the lesson
Design
• program
• pseudocode
• flowchart
• algorithm
PSPD Using C Slide 3 of 40
Problem Solving Techniques
Design
DEVISING A PLAN
Second: Have you seen it before? Or have you
Find the connection seen the same problem in slightly different
between the data and form?
the unknown. Do you know a related problem?
Auxiliary problems Look at the unknown! Try to think of a
may be devised if familiar problem having the same or similar
needed. unknown. Split the problem into smaller,
You should obtain simple sub-problems. If you cannot solve
eventually a plan of the proposed problem try to solve first
the solution. some related problem. Or solve more
general problem. Or special case of the
problem. Or solve the part of the problem.
Examine the Can you check the result? Can you derive
solution the result differently? Can you use the
obtained. result, or the method, for some other
problem?
Algorithmic problem:
Any problem whose solution can be expressed as a
set of executable instructions.
Algorithm:
A well defined computational procedure consisting of
a set of instructions, that takes some value or set of
values, as input, and produces some value or set of
values, as output.
Ingredient
Al-gong
Bah-kut-the
PROBLEM:
=
PSPD Using C Slide 17 of 40
Problem Solving
Design
Processing
(Brains)
Input
Output
CPU
(Brains)
Input Device
Processing
5 10
5 + 10 = 15
15
Input
Output
Let us assume we are interested in calculating the sum of 5
and 10.
PSPD Using C Slide 20 of 40
Problem Solving
Design
Value2
Value1
Sum = Value1 + Value2
Sum
The word variable comes from the word vary, which means
that whatever you place within a variable can be changed.
Value1 Sum
Value2
+ addition
- subtraction
* multiplication
/ division
= assignment
() brackets for grouping calculations
IF (expression) THEN
:
:
ENDIF
PSPD Using C Slide 33 of 40
Decision Making
Design
IF (expression) THEN
:
:
ENDIF
Statements are
placed here.
PSPD Using C Slide 34 of 40
Decision Making
Design
Example:-
We are looking for a job which pays more than
RM4000.
Example of an
Expression
IF (Salary>4000) THEN
Say "I Will Take The Job!!"
ENDIF
For Example:
DOWHILE...ENDDO
FOR…NEXT
REPEAT...UNTIL
REPEAT
:
:
:
UNTIL (expression)
Group of An expression which determines
statements whether the loop will continue.
PSPD Using C Slide 50 of 40
Looping Constructs
Design
Example:
Calculate 8
Display
Calculate 21
Display
Calculate 24
Display
process storage
decision document
making
input/output connector
arrowheads
PSPD Using C Slide 62 of 40
Program Flowcharts
Begin Design
Read Value1,
Value2
Calculate
Sum = Value1 + Value2
Display
Sum
End
Read Amount
YES NO
Amount>20.00?
Calculate Calculate
Actual=Amount * 0.80 Actual=Amount
End
Definition:
A flowchart is a graph consisting of geometrical shapes
that are connected by flow lines.
statement_1 Statement -1
statement_2
------------ Statement -2
statement_n
Statement -n
Pseudocode: Flowchart:
if condition
then-part
else false true
condition
else-part
end_if
else-part then-part
Pseudocode: Flowchart:
if condition
Y
then-part true
end_if condition
N
then-part
false
Pseudocode: Flowchart:
while condition
loop-body
end-while T
Y
condition loop-body
F
N
• Problem Solving
• Pseudocodes
• Flowcharts