SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

The msg box function and the messagebox class
The msg box function and the messagebox classThe msg box function and the messagebox class
The msg box function and the messagebox classFaisal Aziz
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMRajendran
 
Operator precedance parsing
Operator precedance parsingOperator precedance parsing
Operator precedance parsingsanchi29
 
Solving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relationsSolving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relationsDr. Maamoun Ahmed
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal languageRabia Khalid
 
Design and Analysis of algorithms
Design and Analysis of algorithmsDesign and Analysis of algorithms
Design and Analysis of algorithmsDr. Rupa Ch
 
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Ra'Fat Al-Msie'deen
 
Prolog example explanation(Family Tree)
Prolog example explanation(Family Tree)Prolog example explanation(Family Tree)
Prolog example explanation(Family Tree)Gayan Geethanjana
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingR Islam
 
Semantic nets in artificial intelligence
Semantic nets in artificial intelligenceSemantic nets in artificial intelligence
Semantic nets in artificial intelligenceharshita virwani
 
Top Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTanzeela_Hussain
 
CMSC 56 | Lecture 2: Propositional Equivalences
CMSC 56 | Lecture 2: Propositional EquivalencesCMSC 56 | Lecture 2: Propositional Equivalences
CMSC 56 | Lecture 2: Propositional Equivalencesallyn joy calcaben
 
context free language
context free languagecontext free language
context free languagekhush_boo31
 
Relation matrix & graphs in relations
Relation matrix &  graphs in relationsRelation matrix &  graphs in relations
Relation matrix & graphs in relationsRachana Pathak
 

Was ist angesagt? (20)

The msg box function and the messagebox class
The msg box function and the messagebox classThe msg box function and the messagebox class
The msg box function and the messagebox class
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
 
Propositional Logic and Pridicate logic
Propositional Logic and Pridicate logicPropositional Logic and Pridicate logic
Propositional Logic and Pridicate logic
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEM
 
Operator precedance parsing
Operator precedance parsingOperator precedance parsing
Operator precedance parsing
 
Solving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relationsSolving linear homogeneous recurrence relations
Solving linear homogeneous recurrence relations
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal language
 
Turing machines
Turing machinesTuring machines
Turing machines
 
Design and Analysis of algorithms
Design and Analysis of algorithmsDesign and Analysis of algorithms
Design and Analysis of algorithms
 
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
 
Prolog example explanation(Family Tree)
Prolog example explanation(Family Tree)Prolog example explanation(Family Tree)
Prolog example explanation(Family Tree)
 
LR(1) and SLR(1) parsing
LR(1) and SLR(1) parsingLR(1) and SLR(1) parsing
LR(1) and SLR(1) parsing
 
Semantic nets in artificial intelligence
Semantic nets in artificial intelligenceSemantic nets in artificial intelligence
Semantic nets in artificial intelligence
 
Top Down Parsing, Predictive Parsing
Top Down Parsing, Predictive ParsingTop Down Parsing, Predictive Parsing
Top Down Parsing, Predictive Parsing
 
Compiler
CompilerCompiler
Compiler
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
CMSC 56 | Lecture 2: Propositional Equivalences
CMSC 56 | Lecture 2: Propositional EquivalencesCMSC 56 | Lecture 2: Propositional Equivalences
CMSC 56 | Lecture 2: Propositional Equivalences
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 
context free language
context free languagecontext free language
context free language
 
Relation matrix & graphs in relations
Relation matrix &  graphs in relationsRelation matrix &  graphs in relations
Relation matrix & graphs in relations
 

Andere mochten auch

Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and FlowchartsDeva Singh
 
Problem Solving Flow Chart
Problem Solving Flow ChartProblem Solving Flow Chart
Problem Solving Flow ChartRick Presley
 
Flowchart pseudocode-examples
Flowchart pseudocode-examplesFlowchart pseudocode-examples
Flowchart pseudocode-examplesGautam 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 ROBOTalgunastecnocosas
 
Flowchart: A Problem Solving Tool
Flowchart: A Problem Solving ToolFlowchart: A Problem Solving Tool
Flowchart: A Problem Solving ToolQimpro 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 structureRheigh 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 PointSlideShop.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 AutomationRafal 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 problemFrankie Jones
 
ข้อตกลงในการเรียน
ข้อตกลงในการเรียนข้อตกลงในการเรียน
ข้อตกลงในการเรียนManit Wongmool
 

Andere mochten auch (20)

Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 
Problem Solving Flow Chart
Problem Solving Flow ChartProblem Solving Flow Chart
Problem Solving Flow Chart
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Writing algorithms
Writing algorithmsWriting algorithms
Writing algorithms
 
Loops
LoopsLoops
Loops
 
Flowchart pseudocode-examples
Flowchart pseudocode-examplesFlowchart pseudocode-examples
Flowchart pseudocode-examples
 
Business Capability Analysis
Business Capability AnalysisBusiness Capability Analysis
Business Capability Analysis
 
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
 
Flowchart: A Problem Solving Tool
Flowchart: A Problem Solving ToolFlowchart: A Problem Solving Tool
Flowchart: A Problem Solving Tool
 
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
 
9 processing arrays
9 processing arrays9 processing arrays
9 processing arrays
 
서울 미트업 2015 오픈 소스, 워드프레스, 그리고 커뮤니티
서울 미트업 2015   오픈 소스, 워드프레스, 그리고 커뮤니티서울 미트업 2015   오픈 소스, 워드프레스, 그리고 커뮤니티
서울 미트업 2015 오픈 소스, 워드프레스, 그리고 커뮤니티
 
10 data structures
10 data structures10 data structures
10 data structures
 
Flow chart and pseudo code
Flow chart and pseudo code Flow chart and pseudo code
Flow chart and pseudo code
 
Iteration
IterationIteration
Iteration
 
Flowchart Power Point
Flowchart Power PointFlowchart Power Point
Flowchart Power Point
 
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
 
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
 
ECDL
ECDL ECDL
ECDL
 
ข้อตกลงในการเรียน
ข้อตกลงในการเรียนข้อตกลงในการเรียน
ข้อตกลงในการเรียน
 

Ähnlich wie 7 problem solving with loops

CIS110 Computer Programming Design Chapter (3)
CIS110 Computer Programming Design Chapter  (3)CIS110 Computer Programming Design Chapter  (3)
CIS110 Computer Programming Design Chapter (3)Dr. Ahmed Al Zaidy
 
01VD062009003760042.pdf
01VD062009003760042.pdf01VD062009003760042.pdf
01VD062009003760042.pdfSunilMatsagar1
 
R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to MatricesRsquared 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 newbiesVimal 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 frontGreg Landrum
 
Reinforcement learning-ebook-part1
Reinforcement learning-ebook-part1Reinforcement learning-ebook-part1
Reinforcement learning-ebook-part1Rajmeet Singh
 
Reinforcement Learning / E-Book / Part 1
Reinforcement Learning / E-Book / Part 1Reinforcement Learning / E-Book / Part 1
Reinforcement Learning / E-Book / Part 1Hitesh 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 examplesFelipe
 
GLM & GBM in H2O
GLM & GBM in H2OGLM & GBM in H2O
GLM & GBM in H2OSri 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 algorithmIJMIT JOURNAL
 
A boolean modeling for improving
A boolean modeling for improvingA boolean modeling for improving
A boolean modeling for improvingcsandit
 

Ähnlich wie 7 problem solving with loops (20)

3 programming concepts
3 programming concepts3 programming concepts
3 programming concepts
 
CIS110 Computer Programming Design Chapter (3)
CIS110 Computer Programming Design Chapter  (3)CIS110 Computer Programming Design Chapter  (3)
CIS110 Computer Programming Design Chapter (3)
 
01VD062009003760042.pdf
01VD062009003760042.pdf01VD062009003760042.pdf
01VD062009003760042.pdf
 
R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to Matrices
 
cp.docx
cp.docxcp.docx
cp.docx
 
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™
 
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
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Algoritmos
AlgoritmosAlgoritmos
Algoritmos
 
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
 
Reinforcement learning-ebook-part1
Reinforcement learning-ebook-part1Reinforcement learning-ebook-part1
Reinforcement learning-ebook-part1
 
Reinforcement Learning / E-Book / Part 1
Reinforcement Learning / E-Book / Part 1Reinforcement Learning / E-Book / Part 1
Reinforcement Learning / E-Book / Part 1
 
Web UI, Algorithms, and Feature Engineering
Web UI, Algorithms, and Feature Engineering Web UI, Algorithms, and Feature Engineering
Web UI, Algorithms, and Feature Engineering
 
Online Machine Learning: introduction and examples
Online Machine Learning:  introduction and examplesOnline Machine Learning:  introduction and examples
Online Machine Learning: introduction and examples
 
ilp
ilpilp
ilp
 
GLM & GBM in H2O
GLM & GBM in H2OGLM & GBM in H2O
GLM & GBM in H2O
 
algo 1.ppt
algo 1.pptalgo 1.ppt
algo 1.ppt
 
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...
 
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
 
A boolean modeling for improving
A boolean modeling for improvingA boolean modeling for improving
A boolean modeling for improving
 

Mehr von Rheigh Henley Calderon (20)

4 introduction to programming structure
4 introduction to programming structure4 introduction to programming structure
4 introduction to programming structure
 
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
 
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
 
9 technical support
9 technical support9 technical support
9 technical support
 
8 customer service
8 customer service8 customer service
8 customer service
 
7 laptop repair
7 laptop repair7 laptop repair
7 laptop repair
 
6 laptop basics
6 laptop basics6 laptop basics
6 laptop basics
 
5 pc maintenance
5 pc maintenance5 pc maintenance
5 pc maintenance
 
4 pc repair
4 pc repair4 pc repair
4 pc repair
 
3 pc upgrade
3 pc upgrade3 pc upgrade
3 pc upgrade
 
2 pc assembly
2 pc assembly2 pc assembly
2 pc assembly
 
1 hardware fundamentals
1 hardware fundamentals1 hardware fundamentals
1 hardware fundamentals
 
8 cyber crimes
8 cyber crimes8 cyber crimes
8 cyber crimes
 
7 computer ethics
7 computer ethics7 computer ethics
7 computer ethics
 
6 professional ethics
6 professional ethics6 professional ethics
6 professional ethics
 
5 business ethics
5 business ethics5 business ethics
5 business ethics
 
4 human relation
4 human relation4 human relation
4 human relation
 
2 morality
2 morality2 morality
2 morality
 
3 rights and duties
3 rights and duties3 rights and duties
3 rights and duties
 
1 general ethics
1 general ethics1 general ethics
1 general ethics
 

Kürzlich hochgeladen

[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 

Kürzlich hochgeladen (20)

[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 

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