SlideShare a Scribd company logo
1 of 41
APPROACH IN PROBLEM
SOLVING
- Control Structure
• At the end of lesson, student
should able to :
- explain the purpose of looping
control structure
- apply looping control strcuture in
problem soving
- LOOPING / REPETITION
1
LOOPING CONTROL STRUCTURE
2
The essentials of Looping
3
The essentials of Looping
4
The essentials of Looping
5
The essentials of Looping
6
Applying Algorithm in Looping construct
7
Applying Algorithm in Looping construct
Initial value
while
(condition)
statement(s) to be
executed if
condition is TRUE
Updating value
False
True
8
end
Start
Applying Algorithm in Looping construct
9
Applying Algorithm in Looping construct
10
Applying Algorithm in Looping construct
bil=1
while (bil≤4)
bil=bil+1
False
True
Print “hello
world”
11
end
Start
Applying Algorithm in Looping construct
Bil Condition
Bil≤4
Output Updating,
bil=bil+1
1 T Hello world 2
2 T Hello world 3
3 T Hello world 4
4 T Hello world 5
5 F
12
Applying Algorithm in Looping construct
13
Applying Algorithm in Looping construct
14
Applying Algorithm in Looping construct
bil=4
while (bil≥1)
bil=bil-1
False
True
Print “hello
world”
15
end
Start
Applying Algorithm in Looping construct
Bil Condition
Bil≥1
Output Updating,
bil=bil-1
4 T Hello world 3
3 T Hello world 2
2 T Hello world 1
1 T Hello world 0
0 F
16
Applying Algorithm in Looping construct
17
Applying Algorithm in Looping construct
18
Applying Algorithm in Looping construct
bil=1
while (bil≤5)
bil=bil+1
False
True
Input width,
height
area = width x height
Print area
19
end
Start
Applying Algorithm in Looping construct
Bil Condition
Bil≤4
Input width,
height
area=width x
height
Output;
area
Updating,
bil=bil+1
1 T 2
2 T 3
3 T 4
4 T 5
5 T 6
6 F
20
Applying algorithm in looping structure
21
22
End if
bil=1
while
(bil≤20)
bil=bil+1
False
True
Input mark
Print “status
Pass”
if (mark≥50)
Print “status
Fail”
True
False
23
end
Start
Applying algorithm in looping structure
24
Applying Algorithm in Looping construct
25
Applying Algorithm in Looping construct
bil=1
while (bil≤x)
bil=bil+1
False
True
Input radius
area = 22/7 x radius x radius
Print area
Input x
26
end
Start
Sentinel-controlled loop
✓ A sentinel variable is initialized to a specific
value. The while loop continues until,
through some action inside the loop,
the sentinel variable is set to a
predefined termination value.
✓ In the following example the user is asked
to type characters at the keyboard, which
are then appear on the screen, then press
the Enter key when done.
✓ Pressing the Enter key sets the char
variable answer to the ‘N’ character
(defined by the special character ‘N').
27
Sentinel-controlled loop
28
Applying Algorithm in Looping construct
29
Applying Algorithm in Looping construct
Answer = Y
while
(answer ≠ N)
False
True
Print “I Love KMPK”
30
end
Start
Input answer
Accumulating in problem solving
2 1 2 1
31
Accumulating in problem solving
32
Accumulating in problem solving
33
Accumulating in problem solving
bil=1, sum = 0
While
(bil≤50)
bil=bil+1
False
True
Input
number
sum=sum + number
Print sum
* sum printed when
condition is FALSE. Its
because, when the
condition is FALSE, that
means all the 50 numbers
already calculated by
program
34
end
Start
Accumulating in problem solving
35
36
Accumulating in problem solving
bil=1, sum = 0
while
(bil≤50)
bil=bil+1
False
True
Input
number
sum=sum + number
Print sum ,
average
* Average printed when
condition is FALSE. Its
because, average can
calculated when all the
number were input
average=sum/50
37
end
Start
Summary looping
- basic loop
- sentinel-controlled loop
- accumulating loop
38
39
bil=1
while
(bil≤4)
bil=bil+1
False
True
Print
“hello
world”
end
Start
Basic loop
40
end
Start
Sentinel-controlled loop
Answer = Y
while
(answer ≠ N)
False
True
Print “I Love KMPK”
Input answer
41
end
Start
Accumulating loop
bil=1, sum = 0
While
(bil≤50)
bil=bil+1
False
True
Input
number
sum=sum + number
Print sum

More Related Content

What's hot (14)

Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7
 
Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)Infix to Prefix (Conversion, Evaluation, Code)
Infix to Prefix (Conversion, Evaluation, Code)
 
C++ operator
C++ operatorC++ operator
C++ operator
 
Using BigDecimal and double
Using BigDecimal and doubleUsing BigDecimal and double
Using BigDecimal and double
 
To designing counters using verilog code
To designing counters using verilog codeTo designing counters using verilog code
To designing counters using verilog code
 
Day 6 examples u1w14
Day 6 examples u1w14Day 6 examples u1w14
Day 6 examples u1w14
 
Operators-computer programming and utilzation
Operators-computer programming and utilzationOperators-computer programming and utilzation
Operators-computer programming and utilzation
 
Lesson1 Oct 5
Lesson1 Oct 5Lesson1 Oct 5
Lesson1 Oct 5
 
Assignements
AssignementsAssignements
Assignements
 
Chap10alg
Chap10algChap10alg
Chap10alg
 
Lab 1
Lab 1Lab 1
Lab 1
 
BB - Functions (Operations and Piecewise)
BB  - Functions (Operations and Piecewise)BB  - Functions (Operations and Piecewise)
BB - Functions (Operations and Piecewise)
 
MCM FUNCTIONS BLACKBOARD COMPATIBILITY
MCM FUNCTIONS BLACKBOARD COMPATIBILITYMCM FUNCTIONS BLACKBOARD COMPATIBILITY
MCM FUNCTIONS BLACKBOARD COMPATIBILITY
 
Unsupervised program synthesis
Unsupervised program synthesisUnsupervised program synthesis
Unsupervised program synthesis
 

Viewers also liked

8.2 approach in problem solving (9 hour)
8.2 approach in problem solving (9 hour)8.2 approach in problem solving (9 hour)
8.2 approach in problem solving (9 hour)
Fiqry Suryansyah
 
Psp Module 8 Assessment
Psp Module 8 AssessmentPsp Module 8 Assessment
Psp Module 8 Assessment
tina_wilkinson
 
Homework week 5
Homework week 5 Homework week 5
Homework week 5
bissmeyele
 
Heart Attack
Heart AttackHeart Attack
Heart Attack
fwahid
 
Ht ylevaade ja_plaanid
Ht ylevaade ja_plaanidHt ylevaade ja_plaanid
Ht ylevaade ja_plaanid
Papitrolla
 
Mentoring Psp Stream A May09
Mentoring Psp Stream A May09Mentoring Psp Stream A May09
Mentoring Psp Stream A May09
tina_wilkinson
 

Viewers also liked (20)

8.2 approach in problem solving (9 hour)
8.2 approach in problem solving (9 hour)8.2 approach in problem solving (9 hour)
8.2 approach in problem solving (9 hour)
 
Ülesanne
ÜlesanneÜlesanne
Ülesanne
 
PSP Tizianad
PSP TizianadPSP Tizianad
PSP Tizianad
 
Psp Module 8 Assessment
Psp Module 8 AssessmentPsp Module 8 Assessment
Psp Module 8 Assessment
 
Career Talk Planologi ITN, Malang
Career Talk Planologi ITN, MalangCareer Talk Planologi ITN, Malang
Career Talk Planologi ITN, Malang
 
JGI Branding Strategy
JGI Branding StrategyJGI Branding Strategy
JGI Branding Strategy
 
Õppeprotsessi juhtimine digiajastul
Õppeprotsessi juhtimine digiajastulÕppeprotsessi juhtimine digiajastul
Õppeprotsessi juhtimine digiajastul
 
Success In Adversity
Success In AdversitySuccess In Adversity
Success In Adversity
 
The Three Sides to Engagement
The Three Sides to EngagementThe Three Sides to Engagement
The Three Sides to Engagement
 
Homework week 5
Homework week 5 Homework week 5
Homework week 5
 
PSP Keiko
PSP KeikoPSP Keiko
PSP Keiko
 
Gamification - Are you a player in the brand engagement game?
Gamification - Are you a player in the brand engagement game?Gamification - Are you a player in the brand engagement game?
Gamification - Are you a player in the brand engagement game?
 
Heart Attack
Heart AttackHeart Attack
Heart Attack
 
Banking on the Millennial Experience
Banking on the Millennial ExperienceBanking on the Millennial Experience
Banking on the Millennial Experience
 
Majlis Apresiasi UPS2 dan UPS4
Majlis Apresiasi UPS2 dan UPS4Majlis Apresiasi UPS2 dan UPS4
Majlis Apresiasi UPS2 dan UPS4
 
Elder people
Elder peopleElder people
Elder people
 
QR Codes
QR CodesQR Codes
QR Codes
 
Gappei jokaso
Gappei jokasoGappei jokaso
Gappei jokaso
 
Ht ylevaade ja_plaanid
Ht ylevaade ja_plaanidHt ylevaade ja_plaanid
Ht ylevaade ja_plaanid
 
Mentoring Psp Stream A May09
Mentoring Psp Stream A May09Mentoring Psp Stream A May09
Mentoring Psp Stream A May09
 

Similar to 8.2 Looping 1 Feb 2017

Java căn bản - Chapter6
Java căn bản - Chapter6Java căn bản - Chapter6
Java căn bản - Chapter6
Vince Vo
 
Csc1100 lecture05 ch05
Csc1100 lecture05 ch05Csc1100 lecture05 ch05
Csc1100 lecture05 ch05
IIUM
 
Csc1100 lecture03 ch03-pt1-s14
Csc1100 lecture03 ch03-pt1-s14Csc1100 lecture03 ch03-pt1-s14
Csc1100 lecture03 ch03-pt1-s14
IIUM
 
Csc1100 lecture03 ch03-pt1-s14
Csc1100 lecture03 ch03-pt1-s14Csc1100 lecture03 ch03-pt1-s14
Csc1100 lecture03 ch03-pt1-s14
IIUM
 

Similar to 8.2 Looping 1 Feb 2017 (20)

Verilog Lecture4 2014
Verilog Lecture4 2014Verilog Lecture4 2014
Verilog Lecture4 2014
 
lecture8_Cuong.ppt
lecture8_Cuong.pptlecture8_Cuong.ppt
lecture8_Cuong.ppt
 
Control Statement.ppt
Control Statement.pptControl Statement.ppt
Control Statement.ppt
 
Python Lecture 5
Python Lecture 5Python Lecture 5
Python Lecture 5
 
03b loops
03b   loops03b   loops
03b loops
 
Java căn bản - Chapter6
Java căn bản - Chapter6Java căn bản - Chapter6
Java căn bản - Chapter6
 
Csc1100 lecture05 ch05
Csc1100 lecture05 ch05Csc1100 lecture05 ch05
Csc1100 lecture05 ch05
 
Mesics lecture 7 iteration and repetitive executions
Mesics lecture 7   iteration and repetitive executionsMesics lecture 7   iteration and repetitive executions
Mesics lecture 7 iteration and repetitive executions
 
Chapter 6 Balagurusamy Programming ANSI in c
Chapter 6  Balagurusamy Programming ANSI  in cChapter 6  Balagurusamy Programming ANSI  in c
Chapter 6 Balagurusamy Programming ANSI in c
 
Karnaugh
KarnaughKarnaugh
Karnaugh
 
Matlab Script - Loop Control
Matlab Script - Loop ControlMatlab Script - Loop Control
Matlab Script - Loop Control
 
lab-8 (1).pptx
lab-8 (1).pptxlab-8 (1).pptx
lab-8 (1).pptx
 
Stanford splash spring 2016 basic programming
Stanford splash spring 2016 basic programmingStanford splash spring 2016 basic programming
Stanford splash spring 2016 basic programming
 
GE3151_PSPP_UNIT_3_Notes
GE3151_PSPP_UNIT_3_NotesGE3151_PSPP_UNIT_3_Notes
GE3151_PSPP_UNIT_3_Notes
 
Introduction to programming - class 3
Introduction to programming - class 3Introduction to programming - class 3
Introduction to programming - class 3
 
06.Loops
06.Loops06.Loops
06.Loops
 
3.2 looping statement
3.2 looping statement3.2 looping statement
3.2 looping statement
 
Csc1100 lecture03 ch03-pt1-s14
Csc1100 lecture03 ch03-pt1-s14Csc1100 lecture03 ch03-pt1-s14
Csc1100 lecture03 ch03-pt1-s14
 
Csc1100 lecture03 ch03-pt1-s14
Csc1100 lecture03 ch03-pt1-s14Csc1100 lecture03 ch03-pt1-s14
Csc1100 lecture03 ch03-pt1-s14
 
Backtracking & branch and bound
Backtracking & branch and boundBacktracking & branch and bound
Backtracking & branch and bound
 

More from Fizaril Amzari Omar

More from Fizaril Amzari Omar (20)

Chapter 7 Information System
Chapter 7 Information SystemChapter 7 Information System
Chapter 7 Information System
 
Chapter 6 Database SC025 2017/2018
Chapter 6 Database SC025 2017/2018Chapter 6 Database SC025 2017/2018
Chapter 6 Database SC025 2017/2018
 
Chapter 5 Multimedia SC025 2017/2018
Chapter 5 Multimedia SC025 2017/2018Chapter 5 Multimedia SC025 2017/2018
Chapter 5 Multimedia SC025 2017/2018
 
PST SC015 Chapter 2 Computer System 2017/2018
PST SC015 Chapter 2 Computer System 2017/2018PST SC015 Chapter 2 Computer System 2017/2018
PST SC015 Chapter 2 Computer System 2017/2018
 
PDT DC015 Chapter 2 Computer System 2017/2018 (m)
PDT DC015 Chapter 2 Computer System 2017/2018 (m)PDT DC015 Chapter 2 Computer System 2017/2018 (m)
PDT DC015 Chapter 2 Computer System 2017/2018 (m)
 
PDT DC015 Chapter 2 Computer System 2017/2018 (k)
PDT DC015 Chapter 2 Computer System 2017/2018 (k)PDT DC015 Chapter 2 Computer System 2017/2018 (k)
PDT DC015 Chapter 2 Computer System 2017/2018 (k)
 
PDT DC015 Chapter 2 Computer System 2017/2018 (j)
PDT DC015 Chapter 2 Computer System 2017/2018 (j)PDT DC015 Chapter 2 Computer System 2017/2018 (j)
PDT DC015 Chapter 2 Computer System 2017/2018 (j)
 
PDT DC015 Chapter 2 Computer System 2017/2018 (i)
PDT DC015 Chapter 2 Computer System 2017/2018 (i)PDT DC015 Chapter 2 Computer System 2017/2018 (i)
PDT DC015 Chapter 2 Computer System 2017/2018 (i)
 
PDT DC015 Chapter 2 Computer System 2017/2018 (g)
PDT DC015 Chapter 2 Computer System 2017/2018 (g)PDT DC015 Chapter 2 Computer System 2017/2018 (g)
PDT DC015 Chapter 2 Computer System 2017/2018 (g)
 
PDT DC015 Chapter 2 Computer System 2017/2018 (f)
PDT DC015 Chapter 2 Computer System 2017/2018 (f)PDT DC015 Chapter 2 Computer System 2017/2018 (f)
PDT DC015 Chapter 2 Computer System 2017/2018 (f)
 
PDT DC015 Chapter 2 Computer System 2017/2018 (e)
PDT DC015 Chapter 2 Computer System 2017/2018 (e)PDT DC015 Chapter 2 Computer System 2017/2018 (e)
PDT DC015 Chapter 2 Computer System 2017/2018 (e)
 
PDT DC015 Chapter 2 Computer System 2017/2018 (d)
PDT DC015 Chapter 2 Computer System 2017/2018 (d)PDT DC015 Chapter 2 Computer System 2017/2018 (d)
PDT DC015 Chapter 2 Computer System 2017/2018 (d)
 
PDT DC015 Chapter 2 System Concept 2017/2018 (a)
PDT DC015 Chapter 2 System Concept 2017/2018 (a)PDT DC015 Chapter 2 System Concept 2017/2018 (a)
PDT DC015 Chapter 2 System Concept 2017/2018 (a)
 
PST SC015 Chapter 4 Comp. Ethics and Security 2017/2018
PST SC015 Chapter 4 Comp. Ethics and Security 2017/2018PST SC015 Chapter 4 Comp. Ethics and Security 2017/2018
PST SC015 Chapter 4 Comp. Ethics and Security 2017/2018
 
PST SC015 Chapter 3 Internet Technology (V) 2017/2018
PST SC015 Chapter 3 Internet Technology (V)  2017/2018PST SC015 Chapter 3 Internet Technology (V)  2017/2018
PST SC015 Chapter 3 Internet Technology (V) 2017/2018
 
PST SC015 Chapter 3 Internet Technology (IV) 2017/2018
PST SC015 Chapter 3 Internet Technology (IV)  2017/2018PST SC015 Chapter 3 Internet Technology (IV)  2017/2018
PST SC015 Chapter 3 Internet Technology (IV) 2017/2018
 
PST SC015 Chapter 3 Internet Technology (II) 2017/2018
PST SC015 Chapter 3 Internet Technology (II)  2017/2018PST SC015 Chapter 3 Internet Technology (II)  2017/2018
PST SC015 Chapter 3 Internet Technology (II) 2017/2018
 
PST SC015 Chapter 3 Internet Technology (II) 2017/2018
PST SC015 Chapter 3 Internet Technology (II)  2017/2018PST SC015 Chapter 3 Internet Technology (II)  2017/2018
PST SC015 Chapter 3 Internet Technology (II) 2017/2018
 
PST SC015 Chapter 3 Internet Technology (I) 2017/2018
PST SC015 Chapter 3 Internet Technology (I)  2017/2018PST SC015 Chapter 3 Internet Technology (I)  2017/2018
PST SC015 Chapter 3 Internet Technology (I) 2017/2018
 
PST SC015 Chapter 2 Computer System (IV) 2017/2018
PST SC015 Chapter 2 Computer System (IV) 2017/2018PST SC015 Chapter 2 Computer System (IV) 2017/2018
PST SC015 Chapter 2 Computer System (IV) 2017/2018
 

Recently uploaded

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 

8.2 Looping 1 Feb 2017