Topic # 1 - Logic Formulation and Introduction to Programming
Topic # 1 - Logic Formulation and Introduction to Programming
and Introduction
to Programming
Learning
Outcomes UNDERSTAND THE
IMPORTANCE OF LOGIC
FORMULATION
DIFFERENTIATE PROGRAM
STRUCTURES
DESIGN SOLUTIONS TO
PROBLEMS
• implement a procedure
• top-down design
• flowcharts
• pseudocodes
Basic Control Structures
Sequence Selection
Unconditional
Repetition
Jump
• Instructions are executed
in the order they are
written
• Provides the building
block for computer
programs.
• Shows a single action or Sequential
one action followed in
order (sequentially) by
another.
• Actions can be inputs,
processes, or outputs.
Example
1) Go to the phone
2) Dial the pizza place
3) Order the pizza
4) Hang up
Sequential Structure
Selection
• Conditional
• Branching
• Decision
• branches off to different instructions depending on whether a condition is
met
• several blocks of program code is executed based on a test for some
condition
• tells the program which action to take, based on a certain condition
• When a condition is evaluated, its result is either true or false
• If the result is true, one action is performed; if the result is false, a
different action is performed
Example
Single
Selection
Structure
Double Selection
Structure
F T
Multiple Selection
Structure
T
F
LOOPING ITERATION
Repetition
F
Repetition
Structure (for)
F
Repetition Structure
(do-while)
F
Unconditional Branch
Obtain Input
5. Test and
Typing mistakes Debug.
Locate
and
Algorithm flaws remove
any
errors in
Syntax Error the
program.
Logical Error
• designed for future use
• internal documentation -
statements in the program
that are not executed, but
point out the purposes of 6. Complete the
various parts of the documentation:
program
Organize all the
• detailed description of material that
what the program does and
how to use the program describes the
• instruction manual and on-
program.
line help
Computer Program
Display
Multi-document
Manual Input
Preparation
Manual Operation
Some Application Flowcharting Symbols
Punched Tape
Collate
Sort
Extract
Some Application Flowcharting Symbols
Merge
Magnetic Disk
Flowcharting