Sie sind auf Seite 1von 26

ICT1101

PROGRAM LOGIC
FORMULATION
Topic 4: Sequential Logic Structure
Vimala.doraisamy@s.newinti.edu.my
2019
Learning Outcomes

■ Identify the type of logic structures.


■ Use the sequential logic structure to develop a solution to a problem.
■ Use the proper form for instructions in an algorithm and flowchart.
■ Use problem-solving tools to develop a solution to a problem.
Logic Structures

■ Sequential Structure
– Executes instructions one after another.
■ Decision Structure
– Instructions can branch to execute one of two possible sets of instructions.
■ Loop Structure
– Executes a set of instructions many times.

T F

Sequential Decision Loop


Sequential Logic Structure

■ Most commonly used and simplest logic structure.


■ Used together with other logic structures.
■ Instructions are executed from top to bottom without skipping any one of them.
Example – Spot the Problem

Is something missing?

Sub = Number1-Number2

Mul = Number1*Number2

Div = Number1/Number2
Example – Spot the Problem

ENTER Number1 and


Number 2 should be
here.
Sub = Number1-Number2

Mul = Number1*Number2

Div = Number1/Number2
Practice

■ Mary
  is looking for a bank that will give her the most returns on her savings for over
five years. She has RM2000 to put into a savings account. The standard operation to
calculate principal plus interest at the end of a period of time is:

,where P is the principal (amount of money to invest), I is the interest rate (in
percentage), N is the number of years, and M is the compound interval (number of times
per year the interest is calculated and added to the principal).
Analyze: Use Organization Tools

■ Problem Analysis Chart


■ Interactivity/Structure Chart
■ Input-Processing-Output Chart
■ Algorithm
■ Flowchart
PAC

Given Data Required Results

Required Processing Solution Alternatives


PAC

Given Data Required Results


P=2000, I, N=5, M
Required Processing Solution Alternatives
PAC

Given Data Required Results


P=2000, I, N=5, M Amount
Required Processing Solution Alternatives
PAC

Given Data Required Results


P=2000, I, N=5, M Amount
Required Processing Solution Alternatives
Amount=P*(1+I/N)^(N*M)
PAC

Given Data Required Results


P=2000, I, N=5, M Amount
Required Processing Solution Alternatives
Amount=P*(1+I/N)^(N*M) 1. Enter all data as variables. **
2. Enter principle and years as constant and
other data as variables.
3. Process one bank per run. **
4. Process all banks in one run.
Interactivity/Structure
INTEREST
CONTROL
0000
Interactivity/Structure
INTEREST
CONTROL
0000

READ
1000
Interactivity/Structure
INTEREST
CONTROL
0000

READ CALC
1000 2000
Interactivity/Structure
INTEREST
CONTROL
0000

READ CALC PRINT


1000 2000 3000
IPO

Input Processing Module Reference Output


IPO

Input Processing Module Reference Output


P
I
N
M
IPO

Input Processing Module Reference Output


P Start
I Enter P,I,N,M
N Amount=P*(1+I/N)^(N*M)
M Display Amount
End
IPO

Input Processing Module Reference Output


P Start 0000
I Enter P,I,N,M 1000
N Amount=P*(1+I/N)^(N*M) 2000
M Display Amount 3000
End 0000
IPO

Input Processing Module Reference Output


P Start 0000 Amount
I Enter P,I,N,M 1000
N Amount=P*(1+I/N)^(N*M) 2000
M Display Amount 3000
End 0000
Algorithm & Flowchart
Review Learning outcomes

■ Identify the type of logic structures.


■ Use the sequential logic structure to develop a solution to a problem.
■ Use the proper form for instructions in an algorithm and flowchart.
■ Use problem-solving tools to develop a solution to a problem.
Questions?
End of topic 4

Das könnte Ihnen auch gefallen