SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot (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)
 

Viewers also liked

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
 

Viewers also liked (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
 

Similar to Loops

Similar to 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
 

Recently uploaded

Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...jabtakhaidam7
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...Amil baba
 
Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...
Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...
Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...gragchanchal546
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
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
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdfAldoGarca30
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxkalpana413121
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdfKamal Acharya
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...ronahami
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...ppkakm
 
Ground Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementGround Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementDr. Deepak Mudgal
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxNANDHAKUMARA10
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering 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
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 

Recently uploaded (20)

Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...
Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...
Ghuma $ Russian Call Girls Ahmedabad ₹7.5k Pick Up & Drop With Cash Payment 8...
 
Signal Processing and Linear System Analysis
Signal Processing and Linear System AnalysisSignal Processing and Linear System Analysis
Signal Processing and Linear System Analysis
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
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
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...
 
Ground Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementGround Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth Reinforcement
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptx
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering 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
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 

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; }