SlideShare a Scribd company logo
Data Structures and Algorithms




    Problem Solving
    with Loops

The Loop Logic Structure
A third logic structure for designing decisions is the
loop structure. The loop logic structure is the repeating
structure.

     Types of Loop Structures

  @ WHILE / WHILE-END
  @ REPEAT / UNTIL
  @ AUTOMATIC COUNTER LOOP

Incrementing
The task of incrementing, or counting, is done by
adding a constant, such as 1 or 2, to the value of a
variable. To write the instruction to increment a
variable, you use an assignment statement. For
example:

          COUNTER = COUNTER + 1 or C = C+ 1
Problem Solving with Loops                              *Property of STI
                                                           Page 1 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops


Accumulating
Another task that a program must often perform is
accumulating, or summing a group of numbers. The
process of accumulating is similar to incrementing,
except a variable instead of a constant is added to
another variable, which holds the value of the sum or
total. The instruction for accumulating is the
following :

                        SUM = SUM + VARIABLE
                     PRODUCT = PRODUCT * NUMBER




Problem Solving with Loops                              *Property of STI
                                                           Page 2 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

WHILE / WHILE - END
The first of the three types of loop structures is the
WHILE/WHILE-END structure. This type of loop tells
the computer that while the condition is TRUE, repeat
all instructions between the WHILE and the WHILE-
END. The form of the algorithm is the following:

                             WHILE <CONDITION(S)>
                                INSTRUCTION
                                INSTRUCTION
                                .
                                .
                                .
                             WHILE-END




Problem Solving with Loops                                *Property of STI
                                                             Page 3 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Flowchart Diagram of WHILE/WHILE-END




Problem Solving with Loops                    *Property of STI
                                                 Page 4 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Decision Equivalent to WHILE/WHILE-END




Problem Solving with Loops                     *Property of STI
                                                  Page 5 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Problem : Create the algorithm and the flowchart to
find the average age of all the students in a class.




Problem Solving with Loops                          *Property of STI
                                                       Page 6 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Repeat/Until
The second type of loop structure is the REPEAT/UNTIL
structure. This type of loop tells the computer to
repeat the set of instructions between the REPEAT and
the until, until a condition is TRUE. The format of the
REPEAT/UNTIL algorithm is the following:


                             Repeat
                              Instruction
                              Instruction
                             .
                             .
                             .
                             Until <condition(s)>




Problem Solving with Loops                                    *Property of STI
                                                                 Page 7 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Flowchart Diagram of REPEAT/UNTIL




Problem Solving with Loops                     *Property of STI
                                                  Page 8 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Decision Equivalent to REPEAT/UNTIL




Problem Solving with Loops                      *Property of STI
                                                   Page 9 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Problem : Create the algorithm and the flowchart to
find the average age of all the students in a class.




Problem Solving with Loops                          *Property of STI
                                                      Page 10 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Automatic – Counter Loop
The third type of loop structure is the automatic-
counter loop. This type of loop increments or
decrements a variable each time the loop is repeated.
The form of the algorithm for the automatic counter-
loop is the following :

                LOOP:COUNTER = BEGIN TO END STEP S
                 INSTRUCTION
                 INSTRUCTION
                 .
                 .
                 .
                LOOP-END: COUNTER




Problem Solving with Loops                            *Property of STI
                                                        Page 11 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Decision Equivalent to Automatic-Counter Loop




Problem Solving with Loops                       *Property of STI
                                                   Page 12 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Problem : Create the algorithm and the flowchart to
find the average age of all the students in a class.




Problem Solving with Loops                          *Property of STI
                                                      Page 13 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops


Nested Loops
Loops can be nested like decisions can. Each loop must
be nested inside the loop just outside it. The general
rules regarding loops, such as where the condition is
processed and how indentation and brackets are used,
hold true for nested loops as well as single loops.

The inner loops do not have to be the same types of
loop structures as the outer loops; that is, a WHILE/
WHILE-END may be nested inside a REPEAT/UNTIL loop,
or vice versa.




Problem Solving with Loops                           *Property of STI
                                                       Page 14 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Nested Loops




Problem Solving with Loops                  *Property of STI
                                              Page 15 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops




Problem Solving with Loops                  *Property of STI
                                              Page 16 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops

Indicators
Indicators – are logical variables that a programmer
sets within a program to change the processing path
or to control when the processing of a loop should end.

They are sometimes called flags, switches, or trip
values.


Recursion
Another type of loop structure is recursion. Recursion
occurs when a module or a function calls itself.




Problem Solving with Loops                            *Property of STI
                                                        Page 17 of 18
Data Structures and Algorithms




    Problem Solving
    with Loops




Problem Solving with Loops                  *Property of STI
                                              Page 18 of 18
Ad

More Related Content

What's hot (20)

Use case Diagram
Use case Diagram Use case Diagram
Use case Diagram
Rahul Pola
 
Artificial intelligence and knowledge representation
Artificial intelligence and knowledge representationArtificial intelligence and knowledge representation
Artificial intelligence and knowledge representation
Likan Patra
 
Class diagrams
Class diagramsClass diagrams
Class diagrams
Nadia_Nazeer
 
Class based modeling
Class based modelingClass based modeling
Class based modeling
Md. Shafiuzzaman Hira
 
Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram
Ajit Nayak
 
Architectural views
Architectural viewsArchitectural views
Architectural views
Saleem Khan
 
Architecture Design in Software Engineering
Architecture Design in Software EngineeringArchitecture Design in Software Engineering
Architecture Design in Software Engineering
cricket2ime
 
Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12
koolkampus
 
Fundamental of Algorithms
Fundamental of Algorithms Fundamental of Algorithms
Fundamental of Algorithms
Dr Shashikant Athawale
 
Basic Behavioral Modeling
Basic Behavioral ModelingBasic Behavioral Modeling
Basic Behavioral Modeling
AMITJain879
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
Sudarsun Santhiappan
 
Data mining Concepts and Techniques
Data mining Concepts and Techniques Data mining Concepts and Techniques
Data mining Concepts and Techniques
Justin Cletus
 
Uml class-diagram
Uml class-diagramUml class-diagram
Uml class-diagram
ASHOK KUMAR PALAKI
 
Introduction to UML
Introduction to UMLIntroduction to UML
Introduction to UML
Emertxe Information Technologies Pvt Ltd
 
Unit 3(advanced state modeling & interaction meodelling)
Unit  3(advanced state modeling & interaction meodelling)Unit  3(advanced state modeling & interaction meodelling)
Unit 3(advanced state modeling & interaction meodelling)
Manoj Reddy
 
Ch11-Software Engineering 9
Ch11-Software Engineering 9Ch11-Software Engineering 9
Ch11-Software Engineering 9
Ian Sommerville
 
Ch5- Software Engineering 9
Ch5- Software Engineering 9Ch5- Software Engineering 9
Ch5- Software Engineering 9
Ian Sommerville
 
chapter 3-Data Modelling using Entity Relationship .pdf
chapter 3-Data Modelling using Entity Relationship .pdfchapter 3-Data Modelling using Entity Relationship .pdf
chapter 3-Data Modelling using Entity Relationship .pdf
University of Gondar
 
Triggers and active database
Triggers and active databaseTriggers and active database
Triggers and active database
BalaMuruganSamuthira
 
2.3 bayesian classification
2.3 bayesian classification2.3 bayesian classification
2.3 bayesian classification
Krish_ver2
 
Use case Diagram
Use case Diagram Use case Diagram
Use case Diagram
Rahul Pola
 
Artificial intelligence and knowledge representation
Artificial intelligence and knowledge representationArtificial intelligence and knowledge representation
Artificial intelligence and knowledge representation
Likan Patra
 
Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram
Ajit Nayak
 
Architectural views
Architectural viewsArchitectural views
Architectural views
Saleem Khan
 
Architecture Design in Software Engineering
Architecture Design in Software EngineeringArchitecture Design in Software Engineering
Architecture Design in Software Engineering
cricket2ime
 
Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12
koolkampus
 
Basic Behavioral Modeling
Basic Behavioral ModelingBasic Behavioral Modeling
Basic Behavioral Modeling
AMITJain879
 
Data mining Concepts and Techniques
Data mining Concepts and Techniques Data mining Concepts and Techniques
Data mining Concepts and Techniques
Justin Cletus
 
Unit 3(advanced state modeling & interaction meodelling)
Unit  3(advanced state modeling & interaction meodelling)Unit  3(advanced state modeling & interaction meodelling)
Unit 3(advanced state modeling & interaction meodelling)
Manoj Reddy
 
Ch11-Software Engineering 9
Ch11-Software Engineering 9Ch11-Software Engineering 9
Ch11-Software Engineering 9
Ian Sommerville
 
Ch5- Software Engineering 9
Ch5- Software Engineering 9Ch5- Software Engineering 9
Ch5- Software Engineering 9
Ian Sommerville
 
chapter 3-Data Modelling using Entity Relationship .pdf
chapter 3-Data Modelling using Entity Relationship .pdfchapter 3-Data Modelling using Entity Relationship .pdf
chapter 3-Data Modelling using Entity Relationship .pdf
University of Gondar
 
2.3 bayesian classification
2.3 bayesian classification2.3 bayesian classification
2.3 bayesian classification
Krish_ver2
 

Viewers also liked (20)

6 problem solving with decisions
6 problem solving with decisions6 problem solving with decisions
6 problem solving with decisions
Rheigh Henley Calderon
 
5 problem solving with the sequential logic structure
5 problem solving with the sequential logic structure5 problem solving with the sequential logic structure
5 problem solving with the sequential logic structure
Rheigh Henley Calderon
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
Deva Singh
 
Problem Solving Flow Chart
Problem Solving Flow ChartProblem Solving Flow Chart
Problem Solving Flow Chart
Rick Presley
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Elizabeth de Leon Aler
 
Writing algorithms
Writing algorithmsWriting algorithms
Writing algorithms
Krishna Chaytaniah
 
Loops
LoopsLoops
Loops
Kulachi Hansraj Model School Ashok Vihar
 
Flowchart pseudocode-examples
Flowchart pseudocode-examplesFlowchart pseudocode-examples
Flowchart pseudocode-examples
Gautam Roy
 
Business Capability Analysis
Business Capability AnalysisBusiness Capability Analysis
Business Capability Analysis
Venkadesh Narayanan
 
Practices of robotics with ROBOLAB and LEGO RCX ROBOT
Practices of robotics with ROBOLAB and LEGO RCX ROBOTPractices of robotics with ROBOLAB and LEGO RCX ROBOT
Practices of robotics with ROBOLAB and LEGO RCX ROBOT
algunastecnocosas
 
Flowchart: A Problem Solving Tool
Flowchart: A Problem Solving ToolFlowchart: A Problem Solving Tool
Flowchart: A Problem Solving Tool
Qimpro Consultants
 
8 problem solving with the case logic structure
8 problem solving with the case logic structure8 problem solving with the case logic structure
8 problem solving with the case logic structure
Rheigh Henley Calderon
 
9 processing arrays
9 processing arrays9 processing arrays
9 processing arrays
Rheigh Henley Calderon
 
서울 미트업 2015 오픈 소스, 워드프레스, 그리고 커뮤니티
서울 미트업 2015   오픈 소스, 워드프레스, 그리고 커뮤니티서울 미트업 2015   오픈 소스, 워드프레스, 그리고 커뮤니티
서울 미트업 2015 오픈 소스, 워드프레스, 그리고 커뮤니티
jekkilekki
 
10 data structures
10 data structures10 data structures
10 data structures
Rheigh Henley Calderon
 
Flow chart and pseudo code
Flow chart and pseudo code Flow chart and pseudo code
Flow chart and pseudo code
Niva tharan
 
Iteration
IterationIteration
Iteration
Liam Dunphy
 
Flowchart Power Point
Flowchart Power PointFlowchart Power Point
Flowchart Power Point
SlideShop.com
 
Defying Logic - Business Logic Testing with Automation
Defying Logic - Business Logic Testing with AutomationDefying Logic - Business Logic Testing with Automation
Defying Logic - Business Logic Testing with Automation
Rafal Los
 
2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problem2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problem
Frankie Jones
 
5 problem solving with the sequential logic structure
5 problem solving with the sequential logic structure5 problem solving with the sequential logic structure
5 problem solving with the sequential logic structure
Rheigh Henley Calderon
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
Deva Singh
 
Problem Solving Flow Chart
Problem Solving Flow ChartProblem Solving Flow Chart
Problem Solving Flow Chart
Rick Presley
 
Flowchart pseudocode-examples
Flowchart pseudocode-examplesFlowchart pseudocode-examples
Flowchart pseudocode-examples
Gautam Roy
 
Practices of robotics with ROBOLAB and LEGO RCX ROBOT
Practices of robotics with ROBOLAB and LEGO RCX ROBOTPractices of robotics with ROBOLAB and LEGO RCX ROBOT
Practices of robotics with ROBOLAB and LEGO RCX ROBOT
algunastecnocosas
 
Flowchart: A Problem Solving Tool
Flowchart: A Problem Solving ToolFlowchart: A Problem Solving Tool
Flowchart: A Problem Solving Tool
Qimpro Consultants
 
8 problem solving with the case logic structure
8 problem solving with the case logic structure8 problem solving with the case logic structure
8 problem solving with the case logic structure
Rheigh Henley Calderon
 
서울 미트업 2015 오픈 소스, 워드프레스, 그리고 커뮤니티
서울 미트업 2015   오픈 소스, 워드프레스, 그리고 커뮤니티서울 미트업 2015   오픈 소스, 워드프레스, 그리고 커뮤니티
서울 미트업 2015 오픈 소스, 워드프레스, 그리고 커뮤니티
jekkilekki
 
Flow chart and pseudo code
Flow chart and pseudo code Flow chart and pseudo code
Flow chart and pseudo code
Niva tharan
 
Flowchart Power Point
Flowchart Power PointFlowchart Power Point
Flowchart Power Point
SlideShop.com
 
Defying Logic - Business Logic Testing with Automation
Defying Logic - Business Logic Testing with AutomationDefying Logic - Business Logic Testing with Automation
Defying Logic - Business Logic Testing with Automation
Rafal Los
 
2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problem2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problem
Frankie Jones
 
Ad

Similar to 7 problem solving with loops (20)

3 programming concepts
3 programming concepts3 programming concepts
3 programming concepts
Rheigh Henley Calderon
 
Pertemuan-8 - Advanced Pattern Matching.pptx
Pertemuan-8 - Advanced Pattern Matching.pptxPertemuan-8 - Advanced Pattern Matching.pptx
Pertemuan-8 - Advanced Pattern Matching.pptx
WiliantoGan1
 
01VD062009003760042.pdf
01VD062009003760042.pdf01VD062009003760042.pdf
01VD062009003760042.pdf
SunilMatsagar1
 
R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to Matrices
Rsquared Academy
 
cp.docx
cp.docxcp.docx
cp.docx
Balasubramanian699229
 
Understanding Parallelization of Machine Learning Algorithms in Apache Spark™
Understanding Parallelization of Machine Learning Algorithms in Apache Spark™Understanding Parallelization of Machine Learning Algorithms in Apache Spark™
Understanding Parallelization of Machine Learning Algorithms in Apache Spark™
Databricks
 
A tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbiesA tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbies
Vimal Gupta
 
Algorithm
AlgorithmAlgorithm
Algorithm
Prajakta Bagal
 
Algoritmos
AlgoritmosAlgoritmos
Algoritmos
Fab Lab LIMA
 
Some "challenges" on the open-source/open-data front
Some "challenges" on the open-source/open-data frontSome "challenges" on the open-source/open-data front
Some "challenges" on the open-source/open-data front
Greg Landrum
 
Reinforcement learning-ebook-part1
Reinforcement learning-ebook-part1Reinforcement learning-ebook-part1
Reinforcement learning-ebook-part1
Rajmeet Singh
 
Reinforcement Learning / E-Book / Part 1
Reinforcement Learning / E-Book / Part 1Reinforcement Learning / E-Book / Part 1
Reinforcement Learning / E-Book / Part 1
Hitesh Mohapatra
 
Web UI, Algorithms, and Feature Engineering
Web UI, Algorithms, and Feature Engineering Web UI, Algorithms, and Feature Engineering
Web UI, Algorithms, and Feature Engineering
BigML, Inc
 
Online Machine Learning: introduction and examples
Online Machine Learning:  introduction and examplesOnline Machine Learning:  introduction and examples
Online Machine Learning: introduction and examples
Felipe
 
ilp
ilpilp
ilp
Yu (Ricky) Wang
 
GLM & GBM in H2O
GLM & GBM in H2OGLM & GBM in H2O
GLM & GBM in H2O
Sri Ambati
 
algo 1.ppt
algo 1.pptalgo 1.ppt
algo 1.ppt
example43
 
IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...
IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...
IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...
Yamato OKAMOTO
 
Extended pso algorithm for improvement problems k means clustering algorithm
Extended pso algorithm for improvement problems k means clustering algorithmExtended pso algorithm for improvement problems k means clustering algorithm
Extended pso algorithm for improvement problems k means clustering algorithm
IJMIT JOURNAL
 
A boolean modeling for improving
A boolean modeling for improvingA boolean modeling for improving
A boolean modeling for improving
csandit
 
Pertemuan-8 - Advanced Pattern Matching.pptx
Pertemuan-8 - Advanced Pattern Matching.pptxPertemuan-8 - Advanced Pattern Matching.pptx
Pertemuan-8 - Advanced Pattern Matching.pptx
WiliantoGan1
 
01VD062009003760042.pdf
01VD062009003760042.pdf01VD062009003760042.pdf
01VD062009003760042.pdf
SunilMatsagar1
 
R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to Matrices
Rsquared Academy
 
Understanding Parallelization of Machine Learning Algorithms in Apache Spark™
Understanding Parallelization of Machine Learning Algorithms in Apache Spark™Understanding Parallelization of Machine Learning Algorithms in Apache Spark™
Understanding Parallelization of Machine Learning Algorithms in Apache Spark™
Databricks
 
A tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbiesA tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbies
Vimal Gupta
 
Some "challenges" on the open-source/open-data front
Some "challenges" on the open-source/open-data frontSome "challenges" on the open-source/open-data front
Some "challenges" on the open-source/open-data front
Greg Landrum
 
Reinforcement learning-ebook-part1
Reinforcement learning-ebook-part1Reinforcement learning-ebook-part1
Reinforcement learning-ebook-part1
Rajmeet Singh
 
Reinforcement Learning / E-Book / Part 1
Reinforcement Learning / E-Book / Part 1Reinforcement Learning / E-Book / Part 1
Reinforcement Learning / E-Book / Part 1
Hitesh Mohapatra
 
Web UI, Algorithms, and Feature Engineering
Web UI, Algorithms, and Feature Engineering Web UI, Algorithms, and Feature Engineering
Web UI, Algorithms, and Feature Engineering
BigML, Inc
 
Online Machine Learning: introduction and examples
Online Machine Learning:  introduction and examplesOnline Machine Learning:  introduction and examples
Online Machine Learning: introduction and examples
Felipe
 
GLM & GBM in H2O
GLM & GBM in H2OGLM & GBM in H2O
GLM & GBM in H2O
Sri Ambati
 
IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...
IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...
IntelliLight: A Reinforcement Learning Approach for Intelligent Traffic Light...
Yamato OKAMOTO
 
Extended pso algorithm for improvement problems k means clustering algorithm
Extended pso algorithm for improvement problems k means clustering algorithmExtended pso algorithm for improvement problems k means clustering algorithm
Extended pso algorithm for improvement problems k means clustering algorithm
IJMIT JOURNAL
 
A boolean modeling for improving
A boolean modeling for improvingA boolean modeling for improving
A boolean modeling for improving
csandit
 
Ad

More from Rheigh Henley Calderon (20)

4 introduction to programming structure
4 introduction to programming structure4 introduction to programming structure
4 introduction to programming structure
Rheigh Henley Calderon
 
2 beginning problem solving concepts for the computer
2 beginning problem solving concepts for the computer2 beginning problem solving concepts for the computer
2 beginning problem solving concepts for the computer
Rheigh Henley Calderon
 
1 introduction to problem solving and programming
1 introduction to problem solving and programming1 introduction to problem solving and programming
1 introduction to problem solving and programming
Rheigh Henley Calderon
 
9 technical support
9 technical support9 technical support
9 technical support
Rheigh Henley Calderon
 
8 customer service
8 customer service8 customer service
8 customer service
Rheigh Henley Calderon
 
7 laptop repair
7 laptop repair7 laptop repair
7 laptop repair
Rheigh Henley Calderon
 
6 laptop basics
6 laptop basics6 laptop basics
6 laptop basics
Rheigh Henley Calderon
 
5 pc maintenance
5 pc maintenance5 pc maintenance
5 pc maintenance
Rheigh Henley Calderon
 
4 pc repair
4 pc repair4 pc repair
4 pc repair
Rheigh Henley Calderon
 
3 pc upgrade
3 pc upgrade3 pc upgrade
3 pc upgrade
Rheigh Henley Calderon
 
2 pc assembly
2 pc assembly2 pc assembly
2 pc assembly
Rheigh Henley Calderon
 
1 hardware fundamentals
1 hardware fundamentals1 hardware fundamentals
1 hardware fundamentals
Rheigh Henley Calderon
 
8 cyber crimes
8 cyber crimes8 cyber crimes
8 cyber crimes
Rheigh Henley Calderon
 
7 computer ethics
7 computer ethics7 computer ethics
7 computer ethics
Rheigh Henley Calderon
 
6 professional ethics
6 professional ethics6 professional ethics
6 professional ethics
Rheigh Henley Calderon
 
5 business ethics
5 business ethics5 business ethics
5 business ethics
Rheigh Henley Calderon
 
2 morality
2 morality2 morality
2 morality
Rheigh Henley Calderon
 
3 rights and duties
3 rights and duties3 rights and duties
3 rights and duties
Rheigh Henley Calderon
 
1 general ethics
1 general ethics1 general ethics
1 general ethics
Rheigh Henley Calderon
 

Recently uploaded (20)

The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Unlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive GuideUnlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive Guide
vikasascentbpo
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Unlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive GuideUnlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive Guide
vikasascentbpo
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 

7 problem solving with loops

  • 1. Data Structures and Algorithms Problem Solving with Loops The Loop Logic Structure A third logic structure for designing decisions is the loop structure. The loop logic structure is the repeating structure. Types of Loop Structures @ WHILE / WHILE-END @ REPEAT / UNTIL @ AUTOMATIC COUNTER LOOP Incrementing The task of incrementing, or counting, is done by adding a constant, such as 1 or 2, to the value of a variable. To write the instruction to increment a variable, you use an assignment statement. For example: COUNTER = COUNTER + 1 or C = C+ 1 Problem Solving with Loops *Property of STI Page 1 of 18
  • 2. Data Structures and Algorithms Problem Solving with Loops Accumulating Another task that a program must often perform is accumulating, or summing a group of numbers. The process of accumulating is similar to incrementing, except a variable instead of a constant is added to another variable, which holds the value of the sum or total. The instruction for accumulating is the following : SUM = SUM + VARIABLE PRODUCT = PRODUCT * NUMBER Problem Solving with Loops *Property of STI Page 2 of 18
  • 3. Data Structures and Algorithms Problem Solving with Loops WHILE / WHILE - END The first of the three types of loop structures is the WHILE/WHILE-END structure. This type of loop tells the computer that while the condition is TRUE, repeat all instructions between the WHILE and the WHILE- END. The form of the algorithm is the following: WHILE <CONDITION(S)> INSTRUCTION INSTRUCTION . . . WHILE-END Problem Solving with Loops *Property of STI Page 3 of 18
  • 4. Data Structures and Algorithms Problem Solving with Loops Flowchart Diagram of WHILE/WHILE-END Problem Solving with Loops *Property of STI Page 4 of 18
  • 5. Data Structures and Algorithms Problem Solving with Loops Decision Equivalent to WHILE/WHILE-END Problem Solving with Loops *Property of STI Page 5 of 18
  • 6. Data Structures and Algorithms Problem Solving with Loops Problem : Create the algorithm and the flowchart to find the average age of all the students in a class. Problem Solving with Loops *Property of STI Page 6 of 18
  • 7. Data Structures and Algorithms Problem Solving with Loops Repeat/Until The second type of loop structure is the REPEAT/UNTIL structure. This type of loop tells the computer to repeat the set of instructions between the REPEAT and the until, until a condition is TRUE. The format of the REPEAT/UNTIL algorithm is the following: Repeat Instruction Instruction . . . Until <condition(s)> Problem Solving with Loops *Property of STI Page 7 of 18
  • 8. Data Structures and Algorithms Problem Solving with Loops Flowchart Diagram of REPEAT/UNTIL Problem Solving with Loops *Property of STI Page 8 of 18
  • 9. Data Structures and Algorithms Problem Solving with Loops Decision Equivalent to REPEAT/UNTIL Problem Solving with Loops *Property of STI Page 9 of 18
  • 10. Data Structures and Algorithms Problem Solving with Loops Problem : Create the algorithm and the flowchart to find the average age of all the students in a class. Problem Solving with Loops *Property of STI Page 10 of 18
  • 11. Data Structures and Algorithms Problem Solving with Loops Automatic – Counter Loop The third type of loop structure is the automatic- counter loop. This type of loop increments or decrements a variable each time the loop is repeated. The form of the algorithm for the automatic counter- loop is the following : LOOP:COUNTER = BEGIN TO END STEP S INSTRUCTION INSTRUCTION . . . LOOP-END: COUNTER Problem Solving with Loops *Property of STI Page 11 of 18
  • 12. Data Structures and Algorithms Problem Solving with Loops Decision Equivalent to Automatic-Counter Loop Problem Solving with Loops *Property of STI Page 12 of 18
  • 13. Data Structures and Algorithms Problem Solving with Loops Problem : Create the algorithm and the flowchart to find the average age of all the students in a class. Problem Solving with Loops *Property of STI Page 13 of 18
  • 14. Data Structures and Algorithms Problem Solving with Loops Nested Loops Loops can be nested like decisions can. Each loop must be nested inside the loop just outside it. The general rules regarding loops, such as where the condition is processed and how indentation and brackets are used, hold true for nested loops as well as single loops. The inner loops do not have to be the same types of loop structures as the outer loops; that is, a WHILE/ WHILE-END may be nested inside a REPEAT/UNTIL loop, or vice versa. Problem Solving with Loops *Property of STI Page 14 of 18
  • 15. Data Structures and Algorithms Problem Solving with Loops Nested Loops Problem Solving with Loops *Property of STI Page 15 of 18
  • 16. Data Structures and Algorithms Problem Solving with Loops Problem Solving with Loops *Property of STI Page 16 of 18
  • 17. Data Structures and Algorithms Problem Solving with Loops Indicators Indicators – are logical variables that a programmer sets within a program to change the processing path or to control when the processing of a loop should end. They are sometimes called flags, switches, or trip values. Recursion Another type of loop structure is recursion. Recursion occurs when a module or a function calls itself. Problem Solving with Loops *Property of STI Page 17 of 18
  • 18. Data Structures and Algorithms Problem Solving with Loops Problem Solving with Loops *Property of STI Page 18 of 18