SlideShare une entreprise Scribd logo
1  sur  37
MTS 3013
STRUCTURED
PROGRAMMING
INTRODUCTION
Never tire of learning new things. Stretch your
mind. Broaden your experience.
Introduction
 A computer is an electronic device capable of
performing commands given by human.
 Program – Are sequences of instructions and
decisions that the computer carries out to
achieve a task
 Programmer – person responsible in writing a
program
Defining Control Structures
 All computer programs are written using one
or more of three basic structures:
 Sequence
 Repetition
 Selection
 These are called control structures or logic
structures because they control the flow of a
program’s logic.
The sequence structure
 You use it each time you follow a set of
directions, in order, from beginning to end.
 Example – a cookie recipe – you need to
follow each recipe instruction in order,
beginning with the first instruction and ending
the last
 Example – a robot named Didi. Didi can understand
only a specific number of instructions / commands :
walk, turn, sit
 Walk – takes one complete step forward
 Turn – turns 180 degree
 Sit – sits down
 Assume that Didi is facing a chair that is two steps
away from him.
 Write the instructions using only commands that Didi
understands, that direct Didi to sit in the chair.
1. Walk
2. Walk
3. Turn
4. Sit 2 steps
algorithm
A set of step-by-step
instructions that
accomplish a task
The repetition structure
 Example – shampoo bottles typically include
repetition structure in the directions for
washing your hair. Those direction usually tell
you to repeat the “apply shampoo to hair”,
“lather”, and “rinse” steps until your hair is
clean.
 Repetition structure referred to as loop,
directs the computer to repeat one or more
instructions until some condition is met, at
which time the computer should stop
repeating the instructions.
 Example : Didi is facing a chair that is 50
steps away from him. Write the algorithm that
directs Didi to sit in the chair.
 Extra command : repeat x times
 Solution:
 Write “walk” instruction 50 times
 Use the “repeat 50 times.”
1. repeat 50 times:
walk
2. turn
3. sit
The selection structure
 Also called decision structure
 Makes a decision, and then takes appropriate
action based on that decision
 Example: you drive your car and approach an
intersection, whether you need to stop or
proceed.
Example
 Example: Didi is holding either a red or yellow
balloon and that he is facing two boxes. One of the
box is colored yellow and the other is colored red.
The two boxes are located 20 steps away from Didi.
Your task is have Didi to drop the balloon into the
appropriate box. The yellow balloon belongs to the
yellow box and the red balloon belongs to the red
box. After Didi drops the balloon you should return
him to the original position.
 You may add additional instructions to Didi’s
instruction set
The algorithm
1. repeat 20 times:
walk
2. if the balloon is red, do this:
drop the balloon in the red box
otherwise
drop the balloon in the yellow box
3. turn
4. repeat 20 times
walk
5. turn
 Calculate the bonus by multiplying the salary 1%
 Calculate the bonus by multiplying the salary 2%
 If the years employed are greater than or equal to 5,
do this:
 If the years employed are less than 5, do this:
 Otherwise, do this:
 Print the bonus
 Read the salary and years employed
 Repeat for each employee:
Exercise
 Assume a company pays an annual bonus to
its employees. The bonus is based on the
number of years the employee has been with
the company. Employees working at the
company for less than 5 years receive a 1%
bonus, all others receive a 2% bonus. Write
an algorithm that prints each employee’s
bonus. Use only the instructions given:
Answer??
Problem Solving
 Problem solving involves:
 Analysis
 Algorithm or pseudo code or flow chart or
combination of them.
Problems Analysis
 Identify problems:
 Input
 Output
 Process
INPUT PROCESS OUTPUT
Problem
 Write a program obtain average of 3 numbers
given by a user. Display the 3 numbers and
the average of the numbers.
Problems Analysis
 Input : 3 numbers
 Process : 1. Add 3 numbers
2. Divide sum of the numbers by 3
 Output : Print 3 numbers & average
Algorithm
 Algorithm
 Any computing problem can be done by executing
a series of actions in a specific order.
 A procedure for solving a problem in terms of the
actions to be executed and the order in which
these actions are to be executed is called an
algorithm.
 Is a logical solution that is inline with our daily
language or mother tongue language.
Algorithm
Start
1. Set sum = 0 and average = 0
2. Read 3 numbers: nom1, nom2, nom3
3. Add 3 numbers
4. Calculate the average, average = (sum)/3
5. Print 3 numbers(nom1, nom2, nom3) and
the average
End
Pseudo code
 Pseudo code
 Is an artificial and informal language
 Usually it is use English language
 Quite similar to programming language
 The purpose of pseudo code is to make
humans who do not understand computer
programming can easily understand the flow
of the problem solving.
Pseudo code
START
SET sum = 0, average = 0
INPUT nom1, nom2, nom3
sum = nom1 + nom2 + nom3
average = sum / 3
PRINT nom1, nom2, nom3
PRINT average
END
Flow Chart
 Flow Chart
 It is represents by using geometry shapes with
connected line
 Use a standard symbol
Flow Chart
TERMINAL
Indicates the beginning or end of an algorithm
PROCESS
Indicates an input computational or data
manipulation.
INPUT / OUTPUT
Indicates an input or output operation
Flow Chart
DECISION
Indicates a decision point in the algorithm
CONNECTOR
Indicates an entry to or exit from another
part of the flowchart
FLOW LINES
Used to connect the flowchart symbols and
indicate the logic flow
LOOP
Indicates the initial, final and increment
values of a loop
Example of a flow chart
START
END
sum = 0, average = 0
Input nom1,nom2, nom3
sum = nom1 + nom2 + nom3
average = sum / 3
print nom1,nom2, nom3
print average
Exercise
 Write an algorithm and a flow chart to
calculate and display a volume of a sphere.
Volume = 4/3 x pi x radius x radius , where pi = 3.41
Solution
 Analyze the problem
 Input :
 Process :
 Output :
radius
Calculate volume of a sphere
Volume = 4/3 x pi x radius x radius
print volume of a sphere
Solution (algorithm)
Start
1. Input radius
2. Calculate volume of a sphere
Volume = 4/3 x pi x radius x radius
3. print volume of a sphere
End
Solution (Flow Chart)
START
END
pi = 3.41
Input radius
Volume = 4/3 x pi x radius x radius
Print volume
Control Structures Flow Chart
 3 types of control structures:
 Sequence structure
 Selection structure
 If
 If… else
 Repetition structure
 For
 While
 Do… while
Flow Chart for Selection
Structure 1
Pseudo code
if condition
statement 1
Condition / Boolean
operator
Statement 1 (inside if
structure)
True
False
Example Pseudo code
if student’s grade is greater than or equal to 60
Print “Passed”
Flow Chart for Selection
Structure 2
Condition / Boolean
operator
true
false
Statement 2 Statement 2
Pseudo code
if condition
statement 1
Else
statement 2
Example Pseudo code
if student’s grade is greater than or equal to 60
Print “Passed”
Else
Print “Failed”
Flow Chart for Repetition
Structure
Condition / Boolean
operator
Statement 1 (inside if
structure)
True
False
Example Pseudo code
While there are more items on the shopping list
Purchase next item and cross it off my list
Module Structure
 Used for a big and complex problem
 Divide the problem into smaller problem –
sub module
 To simplify a problem solving
Module structure Pseudo code
Main module
Call sub module
End of main module
Sub module name
Statements
End of sub module
Main module
Sub module
1
Sub module
2
TQ

Contenu connexe

Tendances

STRUCTURED PROGRAMMING Chap2
STRUCTURED PROGRAMMING Chap2STRUCTURED PROGRAMMING Chap2
STRUCTURED PROGRAMMING Chap2Bro Shola Ajayi
 
Algorithm and c language
Algorithm and c languageAlgorithm and c language
Algorithm and c languagekamalbeydoun
 
problem solving and design By ZAK
problem solving and design By ZAKproblem solving and design By ZAK
problem solving and design By ZAKTabsheer Hasan
 
Software develop....
Software develop.... Software develop....
Software develop.... GCWUS
 
Programming concepts By ZAK
Programming concepts By ZAKProgramming concepts By ZAK
Programming concepts By ZAKTabsheer Hasan
 
Algorithm - Introduction
Algorithm - IntroductionAlgorithm - Introduction
Algorithm - IntroductionMadhu Bala
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
Pseudocode-Flowchart
Pseudocode-FlowchartPseudocode-Flowchart
Pseudocode-Flowchartlotlot
 
Pseudocode algorithim flowchart
Pseudocode algorithim flowchartPseudocode algorithim flowchart
Pseudocode algorithim flowchartfika sweety
 
Jeremiah Yancy - Objectives for Software design and testing
Jeremiah Yancy - Objectives for Software design and testingJeremiah Yancy - Objectives for Software design and testing
Jeremiah Yancy - Objectives for Software design and testingJeremiah Yancy
 
Programming flowcharts for C Language
Programming flowcharts for C LanguageProgramming flowcharts for C Language
Programming flowcharts for C LanguageAryan Ajmer
 

Tendances (20)

STRUCTURED PROGRAMMING Chap2
STRUCTURED PROGRAMMING Chap2STRUCTURED PROGRAMMING Chap2
STRUCTURED PROGRAMMING Chap2
 
Modular programming
Modular programmingModular programming
Modular programming
 
Programing techniques
Programing techniquesPrograming techniques
Programing techniques
 
Basic of qbasic
Basic of qbasicBasic of qbasic
Basic of qbasic
 
Algorithm and c language
Algorithm and c languageAlgorithm and c language
Algorithm and c language
 
problem solving and design By ZAK
problem solving and design By ZAKproblem solving and design By ZAK
problem solving and design By ZAK
 
The Knowledge of QBasic
The Knowledge of QBasicThe Knowledge of QBasic
The Knowledge of QBasic
 
Unit 3
Unit 3Unit 3
Unit 3
 
Software develop....
Software develop.... Software develop....
Software develop....
 
Programming concepts By ZAK
Programming concepts By ZAKProgramming concepts By ZAK
Programming concepts By ZAK
 
Algorithm - Introduction
Algorithm - IntroductionAlgorithm - Introduction
Algorithm - Introduction
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Modular programming in qbasic
Modular programming in qbasicModular programming in qbasic
Modular programming in qbasic
 
Pseudocode-Flowchart
Pseudocode-FlowchartPseudocode-Flowchart
Pseudocode-Flowchart
 
Lec 1 intro
Lec 1 introLec 1 intro
Lec 1 intro
 
Pseudocode algorithim flowchart
Pseudocode algorithim flowchartPseudocode algorithim flowchart
Pseudocode algorithim flowchart
 
Jeremiah Yancy - Objectives for Software design and testing
Jeremiah Yancy - Objectives for Software design and testingJeremiah Yancy - Objectives for Software design and testing
Jeremiah Yancy - Objectives for Software design and testing
 
Raptor tool
Raptor toolRaptor tool
Raptor tool
 
Programming flowcharts for C Language
Programming flowcharts for C LanguageProgramming flowcharts for C Language
Programming flowcharts for C Language
 

Similaire à Pengenalan kepada pengaturcaraan berstruktur

Problem solving (C++ Programming)
Problem solving (C++ Programming)Problem solving (C++ Programming)
Problem solving (C++ Programming)Umair Younas
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartSachin Goyani
 
Std 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem SolvingStd 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem SolvingNuzhat Memon
 
ALGORITHM PPT GUIDE.pdf
ALGORITHM PPT GUIDE.pdfALGORITHM PPT GUIDE.pdf
ALGORITHM PPT GUIDE.pdfmeychu1
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sitSaurabh846965
 
Algorithms and how to write an algorithms
Algorithms and how to write an algorithmsAlgorithms and how to write an algorithms
Algorithms and how to write an algorithmsAhmed Nobi
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptReshuReshma8
 
Psuedocode1, algorithm1, Flowchart1.pptx
Psuedocode1, algorithm1, Flowchart1.pptxPsuedocode1, algorithm1, Flowchart1.pptx
Psuedocode1, algorithm1, Flowchart1.pptxMattFlordeliza1
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowchartsmoazwinner
 
CSC1100 - Chapter12 - Flow Charts
CSC1100 - Chapter12 - Flow ChartsCSC1100 - Chapter12 - Flow Charts
CSC1100 - Chapter12 - Flow ChartsYhal Htet Aung
 
"A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm ""A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm "CHANDAN KUMAR
 
Lec-ProblemSolving.pptx
Lec-ProblemSolving.pptxLec-ProblemSolving.pptx
Lec-ProblemSolving.pptxmiansaad18
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdfishan743441
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowchartskhair20
 
256958.ppt
256958.ppt256958.ppt
256958.pptBimlesh7
 

Similaire à Pengenalan kepada pengaturcaraan berstruktur (20)

3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Problem solving (C++ Programming)
Problem solving (C++ Programming)Problem solving (C++ Programming)
Problem solving (C++ Programming)
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Std 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem SolvingStd 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem Solving
 
Lesson 3
Lesson 3Lesson 3
Lesson 3
 
ALGORITHM PPT GUIDE.pdf
ALGORITHM PPT GUIDE.pdfALGORITHM PPT GUIDE.pdf
ALGORITHM PPT GUIDE.pdf
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sit
 
Algorithms and how to write an algorithms
Algorithms and how to write an algorithmsAlgorithms and how to write an algorithms
Algorithms and how to write an algorithms
 
Penyelesaian masalah
Penyelesaian masalahPenyelesaian masalah
Penyelesaian masalah
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
 
Psuedocode1, algorithm1, Flowchart1.pptx
Psuedocode1, algorithm1, Flowchart1.pptxPsuedocode1, algorithm1, Flowchart1.pptx
Psuedocode1, algorithm1, Flowchart1.pptx
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowcharts
 
CSC1100 - Chapter12 - Flow Charts
CSC1100 - Chapter12 - Flow ChartsCSC1100 - Chapter12 - Flow Charts
CSC1100 - Chapter12 - Flow Charts
 
Fundamentals of Programming Chapter 3
Fundamentals of Programming Chapter 3Fundamentals of Programming Chapter 3
Fundamentals of Programming Chapter 3
 
"A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm ""A short and knowledgeable concept about Algorithm "
"A short and knowledgeable concept about Algorithm "
 
Lec-ProblemSolving.pptx
Lec-ProblemSolving.pptxLec-ProblemSolving.pptx
Lec-ProblemSolving.pptx
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
 
256958.ppt
256958.ppt256958.ppt
256958.ppt
 

Plus de Unit Kediaman Luar Kampus (8)

Fungsi (i)
Fungsi (i)Fungsi (i)
Fungsi (i)
 
Fail
FailFail
Fail
 
Fungsi (ii)
Fungsi (ii)Fungsi (ii)
Fungsi (ii)
 
Basic pengaturcaraan
Basic pengaturcaraanBasic pengaturcaraan
Basic pengaturcaraan
 
Latihan 2
Latihan 2Latihan 2
Latihan 2
 
Pengaturcaraan asas
Pengaturcaraan asasPengaturcaraan asas
Pengaturcaraan asas
 
Looping
LoopingLooping
Looping
 
Presentation2
Presentation2Presentation2
Presentation2
 

Dernier

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 

Dernier (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 

Pengenalan kepada pengaturcaraan berstruktur

  • 2. Never tire of learning new things. Stretch your mind. Broaden your experience.
  • 3. Introduction  A computer is an electronic device capable of performing commands given by human.  Program – Are sequences of instructions and decisions that the computer carries out to achieve a task  Programmer – person responsible in writing a program
  • 4. Defining Control Structures  All computer programs are written using one or more of three basic structures:  Sequence  Repetition  Selection  These are called control structures or logic structures because they control the flow of a program’s logic.
  • 5. The sequence structure  You use it each time you follow a set of directions, in order, from beginning to end.  Example – a cookie recipe – you need to follow each recipe instruction in order, beginning with the first instruction and ending the last
  • 6.  Example – a robot named Didi. Didi can understand only a specific number of instructions / commands : walk, turn, sit  Walk – takes one complete step forward  Turn – turns 180 degree  Sit – sits down  Assume that Didi is facing a chair that is two steps away from him.  Write the instructions using only commands that Didi understands, that direct Didi to sit in the chair.
  • 7. 1. Walk 2. Walk 3. Turn 4. Sit 2 steps algorithm A set of step-by-step instructions that accomplish a task
  • 8. The repetition structure  Example – shampoo bottles typically include repetition structure in the directions for washing your hair. Those direction usually tell you to repeat the “apply shampoo to hair”, “lather”, and “rinse” steps until your hair is clean.  Repetition structure referred to as loop, directs the computer to repeat one or more instructions until some condition is met, at which time the computer should stop repeating the instructions.
  • 9.  Example : Didi is facing a chair that is 50 steps away from him. Write the algorithm that directs Didi to sit in the chair.  Extra command : repeat x times  Solution:  Write “walk” instruction 50 times  Use the “repeat 50 times.” 1. repeat 50 times: walk 2. turn 3. sit
  • 10. The selection structure  Also called decision structure  Makes a decision, and then takes appropriate action based on that decision  Example: you drive your car and approach an intersection, whether you need to stop or proceed.
  • 11. Example  Example: Didi is holding either a red or yellow balloon and that he is facing two boxes. One of the box is colored yellow and the other is colored red. The two boxes are located 20 steps away from Didi. Your task is have Didi to drop the balloon into the appropriate box. The yellow balloon belongs to the yellow box and the red balloon belongs to the red box. After Didi drops the balloon you should return him to the original position.  You may add additional instructions to Didi’s instruction set
  • 12. The algorithm 1. repeat 20 times: walk 2. if the balloon is red, do this: drop the balloon in the red box otherwise drop the balloon in the yellow box 3. turn 4. repeat 20 times walk 5. turn
  • 13.  Calculate the bonus by multiplying the salary 1%  Calculate the bonus by multiplying the salary 2%  If the years employed are greater than or equal to 5, do this:  If the years employed are less than 5, do this:  Otherwise, do this:  Print the bonus  Read the salary and years employed  Repeat for each employee:
  • 14. Exercise  Assume a company pays an annual bonus to its employees. The bonus is based on the number of years the employee has been with the company. Employees working at the company for less than 5 years receive a 1% bonus, all others receive a 2% bonus. Write an algorithm that prints each employee’s bonus. Use only the instructions given:
  • 16. Problem Solving  Problem solving involves:  Analysis  Algorithm or pseudo code or flow chart or combination of them.
  • 17. Problems Analysis  Identify problems:  Input  Output  Process INPUT PROCESS OUTPUT
  • 18. Problem  Write a program obtain average of 3 numbers given by a user. Display the 3 numbers and the average of the numbers.
  • 19. Problems Analysis  Input : 3 numbers  Process : 1. Add 3 numbers 2. Divide sum of the numbers by 3  Output : Print 3 numbers & average
  • 20. Algorithm  Algorithm  Any computing problem can be done by executing a series of actions in a specific order.  A procedure for solving a problem in terms of the actions to be executed and the order in which these actions are to be executed is called an algorithm.  Is a logical solution that is inline with our daily language or mother tongue language.
  • 21. Algorithm Start 1. Set sum = 0 and average = 0 2. Read 3 numbers: nom1, nom2, nom3 3. Add 3 numbers 4. Calculate the average, average = (sum)/3 5. Print 3 numbers(nom1, nom2, nom3) and the average End
  • 22. Pseudo code  Pseudo code  Is an artificial and informal language  Usually it is use English language  Quite similar to programming language  The purpose of pseudo code is to make humans who do not understand computer programming can easily understand the flow of the problem solving.
  • 23. Pseudo code START SET sum = 0, average = 0 INPUT nom1, nom2, nom3 sum = nom1 + nom2 + nom3 average = sum / 3 PRINT nom1, nom2, nom3 PRINT average END
  • 24. Flow Chart  Flow Chart  It is represents by using geometry shapes with connected line  Use a standard symbol
  • 25. Flow Chart TERMINAL Indicates the beginning or end of an algorithm PROCESS Indicates an input computational or data manipulation. INPUT / OUTPUT Indicates an input or output operation
  • 26. Flow Chart DECISION Indicates a decision point in the algorithm CONNECTOR Indicates an entry to or exit from another part of the flowchart FLOW LINES Used to connect the flowchart symbols and indicate the logic flow LOOP Indicates the initial, final and increment values of a loop
  • 27. Example of a flow chart START END sum = 0, average = 0 Input nom1,nom2, nom3 sum = nom1 + nom2 + nom3 average = sum / 3 print nom1,nom2, nom3 print average
  • 28. Exercise  Write an algorithm and a flow chart to calculate and display a volume of a sphere. Volume = 4/3 x pi x radius x radius , where pi = 3.41
  • 29. Solution  Analyze the problem  Input :  Process :  Output : radius Calculate volume of a sphere Volume = 4/3 x pi x radius x radius print volume of a sphere
  • 30. Solution (algorithm) Start 1. Input radius 2. Calculate volume of a sphere Volume = 4/3 x pi x radius x radius 3. print volume of a sphere End
  • 31. Solution (Flow Chart) START END pi = 3.41 Input radius Volume = 4/3 x pi x radius x radius Print volume
  • 32. Control Structures Flow Chart  3 types of control structures:  Sequence structure  Selection structure  If  If… else  Repetition structure  For  While  Do… while
  • 33. Flow Chart for Selection Structure 1 Pseudo code if condition statement 1 Condition / Boolean operator Statement 1 (inside if structure) True False Example Pseudo code if student’s grade is greater than or equal to 60 Print “Passed”
  • 34. Flow Chart for Selection Structure 2 Condition / Boolean operator true false Statement 2 Statement 2 Pseudo code if condition statement 1 Else statement 2 Example Pseudo code if student’s grade is greater than or equal to 60 Print “Passed” Else Print “Failed”
  • 35. Flow Chart for Repetition Structure Condition / Boolean operator Statement 1 (inside if structure) True False Example Pseudo code While there are more items on the shopping list Purchase next item and cross it off my list
  • 36. Module Structure  Used for a big and complex problem  Divide the problem into smaller problem – sub module  To simplify a problem solving Module structure Pseudo code Main module Call sub module End of main module Sub module name Statements End of sub module Main module Sub module 1 Sub module 2
  • 37. TQ