SlideShare uma empresa Scribd logo
1 de 10
 Problem-Solving .
 Elementary programming.
 Selections.
 Mathematical Functions.
 Characters, and Strings.
 Loops.
 Functions.
 Arrays.
 Objects and classes.
Loops
 Programming languages provide various control structures that allow for more
complicated execution paths.
 A loop statement allows us to execute a statement or group of statements
multiple times and following is the general from of a loop statement in most
of the programming languages:
C++ programming language provides the following
types of loop to handle looping requirements.
Loop Type Description
while loop Repeats a statement or group of
statements while a given condition is
true. It tests the condition before
executing the loop body.
for loop Execute a sequence of statements
multiple times and abbreviates the
code that manages the loop variable.
do...while
loop
Like a while statement, except that
it tests the condition at the end of
the loop body
nested loops You can use one or more loop inside
any another while, for or do..while
loop.
 Loop control statements change execution from its normal sequence. When
execution leaves a scope, all automatic objects that were created in that
scope are destroyed.
Loop Control Statements
C++ supports the following control statements.
Control
Statement
Description
break
statement
Terminates
the loop or switch statement and
transfers execution to the statement
immediately following the loop or
switch.
continue
statement
Causes the loop to skip the
remainder of its body and
immediately retest its condition
prior to reiterating.
goto
statement
Transfers control to the labeled
statement. Though it is not advised
to use goto statement in your
program.
The Infinite Loop
 The Infinite Loop
 A loop becomes infinite loop if a condition never becomes false. The for loop
is traditionally used for this purpose. Since none of the three expressions that
form the for loop are required, you can make an endless loop by leaving the
conditional expression empty.
The Infinite Loop
#include <iostream>
using namespace std;
int main ()
{
for( ; ; ) {
printf("This loop will run forever.n");
}
return 0;
}
 tutorialspoint.com

Mais conteúdo relacionado

Mais procurados (20)

Loops in C
Loops in CLoops in C
Loops in C
 
Loops in c++ programming language
Loops in c++ programming language Loops in c++ programming language
Loops in c++ programming language
 
Loops
LoopsLoops
Loops
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
 
Forloop
ForloopForloop
Forloop
 
Loops
LoopsLoops
Loops
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
 
While loop
While loopWhile loop
While loop
 
Java loops
Java loopsJava loops
Java loops
 
Loop(for, while, do while) condition Presentation
Loop(for, while, do while) condition PresentationLoop(for, while, do while) condition Presentation
Loop(for, while, do while) condition Presentation
 
Do...while loop structure
Do...while loop structureDo...while loop structure
Do...while loop structure
 
While loops
While loopsWhile loops
While loops
 
Nested loop in C language
Nested loop in C languageNested loop in C language
Nested loop in C language
 
Java Repetiotion Statements
Java Repetiotion StatementsJava Repetiotion Statements
Java Repetiotion Statements
 
Looping in c++
Looping in c++Looping in c++
Looping in c++
 
Java input Scanner
Java input Scanner Java input Scanner
Java input Scanner
 
What is while loop?
What is while loop?What is while loop?
What is while loop?
 
Iteration Statement in C++
Iteration Statement in C++Iteration Statement in C++
Iteration Statement in C++
 
Loops in java script
Loops in java scriptLoops in java script
Loops in java script
 
3.looping(iteration statements)
3.looping(iteration statements)3.looping(iteration statements)
3.looping(iteration statements)
 

Destaque

11 ms acces_приемы работыt
11 ms acces_приемы работыt11 ms acces_приемы работыt
11 ms acces_приемы работыtEvgeniy Golendyhin
 
Beginning to Scratch the Surface: Computer Programming for Elementary Students
Beginning to Scratch the Surface: Computer Programming for Elementary StudentsBeginning to Scratch the Surface: Computer Programming for Elementary Students
Beginning to Scratch the Surface: Computer Programming for Elementary StudentsLakeland Central School District
 
Trabajo sobre acces
Trabajo sobre accesTrabajo sobre acces
Trabajo sobre accesFelipe Daza
 
Laporan Sistem Basis Data Ms. Acces
Laporan Sistem Basis Data Ms. AccesLaporan Sistem Basis Data Ms. Acces
Laporan Sistem Basis Data Ms. AccesIsti Qomah
 
Programul Centrului de Excelență și Formare al BNC „Ion Creangă” - Martie 2017
Programul Centrului de Excelență și Formare al BNC „Ion Creangă” - Martie 2017Programul Centrului de Excelență și Formare al BNC „Ion Creangă” - Martie 2017
Programul Centrului de Excelență și Formare al BNC „Ion Creangă” - Martie 2017BibliotecaCreanga
 
State of the Word 2011
State of the Word 2011State of the Word 2011
State of the Word 2011photomatt
 

Destaque (7)

11 ms acces_приемы работыt
11 ms acces_приемы работыt11 ms acces_приемы работыt
11 ms acces_приемы работыt
 
Beginning to Scratch the Surface: Computer Programming for Elementary Students
Beginning to Scratch the Surface: Computer Programming for Elementary StudentsBeginning to Scratch the Surface: Computer Programming for Elementary Students
Beginning to Scratch the Surface: Computer Programming for Elementary Students
 
Cristina Carvaca_Deber
Cristina Carvaca_DeberCristina Carvaca_Deber
Cristina Carvaca_Deber
 
Trabajo sobre acces
Trabajo sobre accesTrabajo sobre acces
Trabajo sobre acces
 
Laporan Sistem Basis Data Ms. Acces
Laporan Sistem Basis Data Ms. AccesLaporan Sistem Basis Data Ms. Acces
Laporan Sistem Basis Data Ms. Acces
 
Programul Centrului de Excelență și Formare al BNC „Ion Creangă” - Martie 2017
Programul Centrului de Excelență și Formare al BNC „Ion Creangă” - Martie 2017Programul Centrului de Excelență și Formare al BNC „Ion Creangă” - Martie 2017
Programul Centrului de Excelență și Formare al BNC „Ion Creangă” - Martie 2017
 
State of the Word 2011
State of the Word 2011State of the Word 2011
State of the Word 2011
 

Semelhante a Loops

Semelhante a Loops (20)

C language 2
C language 2C language 2
C language 2
 
Cse lecture-7-c loop
Cse lecture-7-c loopCse lecture-7-c loop
Cse lecture-7-c loop
 
R loops
R   loopsR   loops
R loops
 
Programming in Arduino (Part 2)
Programming in Arduino  (Part 2)Programming in Arduino  (Part 2)
Programming in Arduino (Part 2)
 
Chapter 3 - Flow of Control Part II.pdf
Chapter 3  - Flow of Control Part II.pdfChapter 3  - Flow of Control Part II.pdf
Chapter 3 - Flow of Control Part II.pdf
 
Loop in C Properties & Applications
Loop in C Properties & ApplicationsLoop in C Properties & Applications
Loop in C Properties & Applications
 
Loop structures
Loop structuresLoop structures
Loop structures
 
web presentation 138.pptx
web presentation 138.pptxweb presentation 138.pptx
web presentation 138.pptx
 
Chapter 9 - Loops in C++
Chapter 9 - Loops in C++Chapter 9 - Loops in C++
Chapter 9 - Loops in C++
 
2nd year computer science chapter 12 notes
2nd year computer science chapter 12 notes2nd year computer science chapter 12 notes
2nd year computer science chapter 12 notes
 
22H51A6755.pptx
22H51A6755.pptx22H51A6755.pptx
22H51A6755.pptx
 
The Loops
The LoopsThe Loops
The Loops
 
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KRLoops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
 
Learn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & LoopsLearn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & Loops
 
Loops in c++
Loops in c++Loops in c++
Loops in c++
 
Loops c++
Loops c++Loops c++
Loops c++
 
Final requirement
Final requirementFinal requirement
Final requirement
 
Matlab loops 2
Matlab loops 2Matlab loops 2
Matlab loops 2
 
Matlab loops
Matlab loopsMatlab loops
Matlab loops
 
Control statements
Control statementsControl statements
Control statements
 

Último

Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...HenryBriggs2
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfsumitt6_25730773
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksMagic Marks
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Ramkumar k
 
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptxrouholahahmadi9876
 

Último (20)

Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdf
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic Marks
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)
 
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
 

Loops

  • 1.
  • 2.  Problem-Solving .  Elementary programming.  Selections.  Mathematical Functions.  Characters, and Strings.  Loops.  Functions.  Arrays.  Objects and classes.
  • 3. Loops  Programming languages provide various control structures that allow for more complicated execution paths.  A loop statement allows us to execute a statement or group of statements multiple times and following is the general from of a loop statement in most of the programming languages:
  • 4. C++ programming language provides the following types of loop to handle looping requirements.
  • 5. Loop Type Description while loop Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body. for loop Execute a sequence of statements multiple times and abbreviates the code that manages the loop variable. do...while loop Like a while statement, except that it tests the condition at the end of the loop body nested loops You can use one or more loop inside any another while, for or do..while loop.
  • 6.  Loop control statements change execution from its normal sequence. When execution leaves a scope, all automatic objects that were created in that scope are destroyed. Loop Control Statements
  • 7. C++ supports the following control statements. Control Statement Description break statement Terminates the loop or switch statement and transfers execution to the statement immediately following the loop or switch. continue statement Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating. goto statement Transfers control to the labeled statement. Though it is not advised to use goto statement in your program.
  • 8. The Infinite Loop  The Infinite Loop  A loop becomes infinite loop if a condition never becomes false. The for loop is traditionally used for this purpose. Since none of the three expressions that form the for loop are required, you can make an endless loop by leaving the conditional expression empty.
  • 9. The Infinite Loop #include <iostream> using namespace std; int main () { for( ; ; ) { printf("This loop will run forever.n"); } return 0; }