You are on page 1of 25

CHAPTER 2:

Structure Program Development

BEE1213: COMPUTER PROGRAMMING

1 YAW- credit to HAA,RAK & AIH


Syllabus

Structure Programming
2.1 Approach

2.2 Software Development

Algorithm, Pseudo-Code
2.3 and Flowchart
2 YAW- credit to HAA,RAK & AIH
Lesson Outcomes
1. Explain the structured programming approach
2. Develop simple algorithm to solve basic
arithmetic operation

3 YAW- credit to HAA,RAK & AIH


2.1 Structure Programming Approach

What is a Program?
A set of instruction for computer to execute
A collection of instructions necessary to solve a
specific problem
SOFTWARE or FIRMWARE?

4 YAW- credit to HAA,RAK & AIH


Programming Paradigm
A point of view on Examples:
how program execute Unstructured

Influence problem Structured


solving methodology Sequential

Procedural or
Functional
Object oriented

5 YAW- credit to HAA,RAK & AIH


Structured Programming
Disciplined approach to writing program that are
clear, correct & easy to maintain
Sequential, procedural or functional

Top-Down approach to programming

6 YAW- credit to HAA,RAK & AIH


Program Execution
Computers execute instruction line-by-line basis
Instructions and data are stored in allocated

memory addresses
Information stored in memory address is
accessed by fetch-execute cycle
Program Counter (PC) store current memory
address information
Registers store current instruction and data
executed

7 YAW- credit to HAA,RAK & AIH


The Memory Structure

8 YAW- credit to HAA,RAK & AIH


2.2 Software Development
Software Development Life Cycle (SDLC)
Six step procedure
Program specification
Program design
Program code
Program test
Program documentation
Program maintenance

9 YAW- credit to HAA,RAK & AIH


Understanding what the problem is?
What is solution should provide?
SDLC Inputs to the problem
Any special constraints/condition/
formulas to be used
75% of total lifetime
cost
Error-free operations
Effective program
Plan a solution
Two categories
Using Algorithm:
Operations
- Pseudocode
Changing needs
- Flowcharts

Written
descriptions and
procedures about a
program
User manual
Transform design to coding
Writing the program or
Debugging coding
Syntax errors
Logic errors
10 YAW- credit to HAA,RAK & AIH
2.3 Algorithm, Pseudo-Code and Flowchart

Algorithm
Method for solving well structured problem
Sequence of steps to accomplish specific task

11 YAW- credit to HAA,RAK & AIH


Representing Algorithm
Flow Chart Pseudo Code
Graphical symbols Algorithmic language

Flow of steps or Code without syntax

processes May use borrowed


Generic syntax
Easily translate

12 YAW- credit to HAA,RAK & AIH


Flow Chart Symbols
start/end

connector
operation

input/output Off-page
connector

decision

13 YAW- credit to HAA,RAK & AIH


Flowchart: Logic Structures

SEQUENCE STRUCTURE SELECTION STRUCTURE LOOP STRUCTURE

14 YAW- credit to HAA,RAK & AIH


Pseudo-code statement
Simple English Pseudo-code
Gets first number input(number1)
Gets second number input(number2)
Add the two numbers Result = number1 +
Show result number2
output(Result)

15 YAW- credit to HAA,RAK & AIH


Example 1: sequence
Problem:
Design a software to calculate the sum of two
numbers entered by user.

16 YAW- credit to HAA,RAK & AIH


Example: Add 2 numbers
(pseudo code) (flowchart) start
Steps:
Read number1
1. Begin

2. Read number1
Read number2
3. Read number2

4. Add number1 & number2 answer=no1+no2

5. Display sum
Display Sum
5. End

end
17 YAW- credit to HAA,RAK & AIH
Solution

18 YAW- credit to HAA,RAK & AIH


Example 2: sequence
Problem:
Design a software to calculate the average of
three numbers entered by user.

19 YAW- credit to HAA,RAK & AIH


Solution

20 YAW- credit to HAA,RAK & AIH


Example 3: selection
Problem:
Read a value from user. If the value is negative, tell
him.

21 YAW- credit to HAA,RAK & AIH


Solution
Start
Begin
input value
if value < 0 then
Input print The value is negative
value
End

FALSE
value < 0?

TRUE

Print The
value is
negative

End

22 YAW- credit to HAA,RAK & AIH


Practice 1
Problem:
Read a value from user. Tell the user whether
the value is negative, zero or positive.

23 YAW- credit to HAA,RAK & AIH


solution
Begin
input value
if value < 0 then
Start print The value is negative
else if value = 0 then
print The value is zero
Input else
value print The value is posifive
End

FALSE FALSE
value < 0? value == 0?

TRUE TRUE

Display Display Display


The value The value The value
is negative is zero is positive

End
24 YAW- credit to HAA,RAK & AIH
END OF CHAPTER 2
1. Q& A
2. Outcomes
Explain the structured programming approach
Develop simple algorithm to solve basic
arithmetic operation
3. Reflection

25 YAW- credit to HAA,RAK & AIH

You might also like