Program Logic Formulation
Program Logic Formulation
Computer Software
• Application software
• System software
Application Software
• A person trained in
the analysis of
complex business
system, which
typically involve a
computer-based
information system.
Systems Development Life Cycle
• Direct
• Parallel
• Pilot
• Phased
Programming
• Program
– List of computer instructions required to
arrive at the desired results.
• Algorithm
– A step-by-step list of instructions for
solving a problem.
– A precisely expressed procedure for
obtaining the problem solution.
Programming
• Programming Language
– A formalize notation that allows algorithms
to be presented in a rigorous and precise
way.
– Types: machine language, assembly
language, high-level language, very high-
level language (or 4GL)
Programming
Format:
OPERATION <operand/s>
where:
OPERATION – pseudocode operation or
instruction
operand/s – object/s of a pseudocode
operation or instruction
Pseudolanguage Instructions
• OPEN
– Allows the program that contains the statement
to have access to the records of the designated
file.
• READ
– Used to copy the contents of a record from an
external magnetic medium into an input
memory area.
Pseudolanguage Instructions
• WRITE
– Used to copy the contents of an output memory
area to a file stored on an external magnetic
medium or a file produced on a printer.
• CLOSE
– Terminates a program’s access to the records of
a file previously opened.
Pseudolanguage Instructions
• IF
– Used to compare the contents of a memory area
with those of another memory area or a
constant in order to determine whether the
condition is true or false.
• PERFORM
– Instructs the computer to perform a specified
procedure.
Pseudolanguage Instructions
• MOVE
– Used to tell the computer that the data
contained in one area in memory is to be copied
to another area in memory.
• COMPUTE
– Used to indicate that a mathematical
computation is to take place.
Pseudolanguage Instructions
• DISPLAY
– Used to display a literal or the contents of an
identifier on the screen.
• ACCEPT
– Allows data entered through the keyboard (or
any input device) to be stored in a memory
area.
Pseudolanguage Instructions
• DECLARE
– Used to define the various identifiers to be used
in a program.
• ENTRY
– Marks the beginning of a procedure.
• EXIT
– Marks the end of a procedure.
Pseudolanguage Instructions
• START
– Marks the beginning of a program’s control
procedure.
• STOP
– Causes the program execution to terminate.
Flowchart Example
MAIN-ROUTINE
F
EOF
A PRINT-ADDRESS T
CLOSE ADDRESS-FILE
MAIL-LABELS-FILE
STOP
Pseudocode Example
BEGIN MAIN-ROUTINE
OPEN INPUT ADDRESS-FILE
OUTPUT MAIL-LABELS-FILE
READ ADDRESS-FILE
PERFORM UNTIL EOF=“T”
PERFORM
PRINT-ADDRESS
END PERFORM
READ ADDRESS-FILE
END PERFORM
CLOSE ADDRESS-FILE
OUTPUT MAIL-LABELS-FILE
END MAIN-ROUTINE
Problem Solving & Solution
Design Concepts
1. Computational
– Problems involving some kind of mathematical
processing
2. Logical
– Involve relational or logical processing
3. Repetitive
– Involve repeating a set of mathematical and/or
logical instructions
Attributes of a Well-designed
Program
MAIN-RTN
planning tool
• Top-down approach EOF-SW=1
F
PROCESS-RTN
• Modular T
• Structured FINAL-RTN
STOP
Logical Control Structures
1. Sequence
2. Selection / Decision
3. Iteration / Loop
4. Case
SEQUENCE
• Instructions are executed in the order in
which they appear
• “Step-by-step” execution of instructions
START
General Representation:
Instruction 1
Instruction 2
Instruction 3
Instruction n
STOP
SELECTION / DECISION
• A logical control structure that execute
instructions depending on the existence of
a condition
• Sometimes called an “If-Then-Else”
logical control structure
General Representation:
F T
Condition met?
Instruction 1 Instruction 2
ITERATION / LOOP
• A logical control structure indicating
the repeated execution of a series of
steps (or instructions).
General Representation:
T
Condition met? Sub-routine
F
CASE
• A logical control structure that is used
when there are numerous paths to be
followed depending on the content of a
given variable.
General Representation:
Variable
ALGORITHM
LOGIC Y
B
ERROR?
CODING
N
TRANSLATION
STOP
SYNTAX Y
DEBUGGING
ERROR?
N B
A
DATA
• Constant
– A value that never changes during the
processing of all the instructions in a solution.
• Variable
– The value of a variable does change during
processing.
– Also called as “identifier”
CONSTANT
• Numeric
• Character
• Logical
• Date / Time
Numerical Data
Data Set
• The set of symbols necessary to specify a
datum as a particular data type.
• Data set for the numerical data type
– All base 10 numbers
– Positive (+) and the negative (-) sign
Character Data
1. Mathematical
2. Relational
3. Logical
Operands
Resultant
• The answer that results when the operation
is completed.
Mathematical Operators
• Include the following:
•+
– Addition
•-
• * – Subtraction
• / – Multiplication
– Division
•\ MOD
• ^ or **
– Integer Division
• FunctionName (parameters)
– Modulo Division
– Powers
– Functions
Relational Operators