Professional Documents
Culture Documents
Chapter 18 - Logic and Introduction To Algorithm Part A
Chapter 18 - Logic and Introduction To Algorithm Part A
INSTITUTE
IGCSE(EdExcel)
U Nyein Oo
Founder
Optimum Institute
Optimum Institute of Business & Technology Studies
of Business & Technology Studies
1
Program Development Steps(cont.)
Algorithm Tools:
– Flowchart
– Pseudo code
– Decision table
– Trace Table(Dry Run/Desk Checking)
– Structured Diagram..etc
2
Flowchart Symbols
3
Pseudo Keywords
Operator
4
Logical operators
Logical operators(cont.)
Operator Meaning Example
AND or && Logical And x > 0 AND x < 10
x > 0 && x < 10
5
Structured Programming
• Structured programming is a program written with only the structured
programming constructions:
– (1) sequence,
– (2) Selection,
– and (3) Iteration.
Sequence
• Sequence is the first programming structure.
Sequence Syntax
Statement 1
Statement 2
Statement 3
-
-
-
Statement n
6
Selection(Conditional Statement)
• Selection is a programming structure where a section of code is run only if a
condition is met.
• There are three sort of selection.
One way selection
Two ways selection
Multi ways selection
7
Sample Exercise for One way Selection
OR = ||
NOT = !
8
Sample Exercise for Logical AND
– IF Marks of subject One >=40 and Marks of Subject Two >=40 then Display
9
Sample Exercise for Logical NOT
– IF given gender type is not “Male” THEN Display message is “ Gender is
Female ”
10
Two way selection
• Based upon the value of the condition (Boolean T or F) choose what to
do next.
• There is another form of IF statement which is IF..THEN …ELSE
statement.
• IF...THEN …ELSE statement helps to reduce the complexity of a
program to some extent and also improves the readability.
IF Condition THEN
Statement 1
Statement 2 True branch
This is executed if then condition is true
------
Statement n
ELSE
Statement 1
False branch
Statement 2
This is executed if then condition is false
-------
Statement n
END IF
11
Pseudocode Example for Two way Selection
Exercise Question
Display the “Result is Pass” message if given
input mark is at least 40 else Display “ Result is
Fail” message
Exercise Question
Display the “Distinction ” message if given input
two subject marks is at least 80 else Display “
Regular Pass ” message
12
Pseudocode Example for Two way Selection with Logical OR
Exercise Question
Display the “Distinction ” message if given input
two subject marks is at least 80 else Display “
Regular Pass ” message
Thank You!
U Nyein Oo
Founder
Optimum Institute of Business & Technology Studies
Optimum Institute of Business & Technology Studies
13