SlideShare a Scribd company logo
1 of 14
Made By :-Made By :-
Deeksha GopaliyaDeeksha Gopaliya
1111thth
ScienceScience
COMPUTERCOMPUTER
PROJECTPROJECT
L O O P I N G
EXIT
LOOPSLOOPS
FORFOR LOOPLOOPFORFOR LOOPLOOP DODO WHILEWHILE
LOOPLOOP
DODO WHILEWHILE
LOOPLOOPWHILEWHILE LOOPLOOPWHILEWHILE LOOPLOOP
PARTS OF A LOOP
1. Initialization Expression - Before entering in a loop , its
control variables must be initialized. The initializations expression
gives the loop variables their first value.
2. Test Expression - The test expression is the expression whose
truth value decides whether the loop body will be executed or not.
3. Update Expression - The update expression change the values of
loop variables. The update expression is executed ; at the end of
the loop after loop body is executed.
4. The body of the Loop – The statements that are executed
repeatedly as long as the condition is true ,form the body of loop.
FOR LOOPFOR LOOP
For Loop executes a sequence of statements
multiple time
and abbreviates the code that manages the loop
variable.
Syntax: for (initialization; condition; update
expression)
Body of the loop;
Example: #include<iostream.h> output:
void main( ) 1
{ 2
for (int i=0; i<=5; i++) 3
Functioning oF For Loop in c++
 For loop is used when we don’t know in advance how many times the loop will
times the loop will be executed .
 The loop terminates as soon as the condition becomes false.
EXIT
WHILEWHILE LOOPLOOP
While loopWhile loop is an entry-controlled loop. It repeats a statement or
group of statements while a condition is true. It tests the
condition before executing the loop.
Syntax: initialization;
while (condition)
loop=body;
updating expression;
Example : #include<iostream.h> Output:
void main( ) 1
{ 2
int i=1 Initialization expression 3
while (i<=5) 4
cout<<“n”<<i; Body of loop 5
i++; Update expression
}
DO WHILE LOOPDO WHILE LOOP
Do while LoopDo while Loop is a exit-controlled loop. It evaluates its text expression at the
bottom of the loop after executing the loop body statements.
Syntax: initialization;
do
{
loop body;
updating expression;
}while (condition);
Example: #include<iostream.h. Output:
void main( ) 1
{int i=1 Initialization expression 2
do 3
{ 4
cout<<“n”<<i; Body of loop 5
i++; Update expression 6
}while (i<=5)
Comparison between
while loop and do while loop
 While loop test condition before executing the loop body whereas do while loop
test condition after executing loop body.
 While loop is a entry-controlled loop whereas do while loop is a exit-controlled
loop.
 While loop is preferred when we don’t want to execute the loop body even once
in case the condition is false whereas do while loop is preferred when we want to
Functioning of Nested Loop
Example:
#include<iostream.h>
void main( )
{
for( int i=1; i<=3; i++)
{
for( int j=1; j<=i; j++)
{
cout<<i;
}
cout<<“n”;
} }
Inner
Loop
Outer
Loop
Output:
11
1212
123123
POWERPOINTPOWERPOINT
PRESENTATIONPRESENTATION
ONON
LOOPINGLOOPING IN C++IN C++
Made By:-Made By:-
Deeksha GopaliyaDeeksha Gopaliya

More Related Content

What's hot

Loops Basics
Loops BasicsLoops Basics
Loops BasicsMushiii
 
Nested loop in C language
Nested loop in C languageNested loop in C language
Nested loop in C languageErumShammim
 
Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Muhammad Tahir Bashir
 
Loop in C Properties & Applications
Loop in C Properties & ApplicationsLoop in C Properties & Applications
Loop in C Properties & ApplicationsEmroz Sardar
 
Chapter 9 - Loops in C++
Chapter 9 - Loops in C++Chapter 9 - Loops in C++
Chapter 9 - Loops in C++Deepak Singh
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loopsbsdeol28
 
Refactoring Edit History of Source Code
Refactoring Edit History of Source CodeRefactoring Edit History of Source Code
Refactoring Edit History of Source CodeShinpei Hayashi
 
What is to loop in c++
What is to loop in c++What is to loop in c++
What is to loop in c++03446940736
 
Introduction to Perl Internals
Introduction to Perl InternalsIntroduction to Perl Internals
Introduction to Perl Internalsℕicolas ℝ.
 

What's hot (16)

Loops Basics
Loops BasicsLoops Basics
Loops Basics
 
Loop structures
Loop structuresLoop structures
Loop structures
 
Nested loop in C language
Nested loop in C languageNested loop in C language
Nested loop in C language
 
Comp ppt (1)
Comp ppt (1)Comp ppt (1)
Comp ppt (1)
 
Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)
 
Loop in C Properties & Applications
Loop in C Properties & ApplicationsLoop in C Properties & Applications
Loop in C Properties & Applications
 
Chapter 9 - Loops in C++
Chapter 9 - Loops in C++Chapter 9 - Loops in C++
Chapter 9 - Loops in C++
 
Looping statements
Looping statementsLooping statements
Looping statements
 
SLF4J+Logback
SLF4J+LogbackSLF4J+Logback
SLF4J+Logback
 
Computer programming 2 Lesson 8
Computer programming 2  Lesson 8Computer programming 2  Lesson 8
Computer programming 2 Lesson 8
 
Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
 
Iteration
IterationIteration
Iteration
 
C++ loop
C++ loop C++ loop
C++ loop
 
Refactoring Edit History of Source Code
Refactoring Edit History of Source CodeRefactoring Edit History of Source Code
Refactoring Edit History of Source Code
 
What is to loop in c++
What is to loop in c++What is to loop in c++
What is to loop in c++
 
Introduction to Perl Internals
Introduction to Perl InternalsIntroduction to Perl Internals
Introduction to Perl Internals
 

Viewers also liked

Comparativeadjectives2 111115100619-phpapp01
Comparativeadjectives2 111115100619-phpapp01Comparativeadjectives2 111115100619-phpapp01
Comparativeadjectives2 111115100619-phpapp01Mohammad Ghoreishi
 
Niels Falk, Divisionsdirektør i MT Højgaard
Niels Falk, Divisionsdirektør i MT HøjgaardNiels Falk, Divisionsdirektør i MT Højgaard
Niels Falk, Divisionsdirektør i MT HøjgaardMikkel Rohde Madsen
 
Rasmus Lassen, Byggechef i Københavns Ejendomme
Rasmus Lassen, Byggechef i Københavns EjendommeRasmus Lassen, Byggechef i Københavns Ejendomme
Rasmus Lassen, Byggechef i Københavns EjendommeMikkel Rohde Madsen
 
Comparativeandsuperlativeadjectives 110509184306-phpapp01
Comparativeandsuperlativeadjectives 110509184306-phpapp01Comparativeandsuperlativeadjectives 110509184306-phpapp01
Comparativeandsuperlativeadjectives 110509184306-phpapp01Mohammad Ghoreishi
 
Morgenmøde GenieBelt 13. juni 2016
Morgenmøde GenieBelt 13. juni 2016Morgenmøde GenieBelt 13. juni 2016
Morgenmøde GenieBelt 13. juni 2016Mikkel Rohde Madsen
 
Morgenmøde om ´BYGGERIET's NYE AKTØRER´
Morgenmøde om ´BYGGERIET's NYE AKTØRER´Morgenmøde om ´BYGGERIET's NYE AKTØRER´
Morgenmøde om ´BYGGERIET's NYE AKTØRER´Mikkel Rohde Madsen
 
Cloud computing
Cloud computingCloud computing
Cloud computingRahul Pola
 
Windows Presentation Foundation & XAML
Windows Presentation Foundation & XAMLWindows Presentation Foundation & XAML
Windows Presentation Foundation & XAMLAlex Sooraj
 
Sequence diagram
Sequence diagramSequence diagram
Sequence diagramRahul Pola
 
Allu Upendra Resume-CE
Allu Upendra Resume-CEAllu Upendra Resume-CE
Allu Upendra Resume-CEUpendra Allu
 

Viewers also liked (11)

Comparativeadjectives2 111115100619-phpapp01
Comparativeadjectives2 111115100619-phpapp01Comparativeadjectives2 111115100619-phpapp01
Comparativeadjectives2 111115100619-phpapp01
 
Niels Falk, Divisionsdirektør i MT Højgaard
Niels Falk, Divisionsdirektør i MT HøjgaardNiels Falk, Divisionsdirektør i MT Højgaard
Niels Falk, Divisionsdirektør i MT Højgaard
 
Rasmus Lassen, Byggechef i Københavns Ejendomme
Rasmus Lassen, Byggechef i Københavns EjendommeRasmus Lassen, Byggechef i Københavns Ejendomme
Rasmus Lassen, Byggechef i Københavns Ejendomme
 
Comparativeandsuperlativeadjectives 110509184306-phpapp01
Comparativeandsuperlativeadjectives 110509184306-phpapp01Comparativeandsuperlativeadjectives 110509184306-phpapp01
Comparativeandsuperlativeadjectives 110509184306-phpapp01
 
Morgenmøde GenieBelt 13. juni 2016
Morgenmøde GenieBelt 13. juni 2016Morgenmøde GenieBelt 13. juni 2016
Morgenmøde GenieBelt 13. juni 2016
 
Morgenmøde om ´BYGGERIET's NYE AKTØRER´
Morgenmøde om ´BYGGERIET's NYE AKTØRER´Morgenmøde om ´BYGGERIET's NYE AKTØRER´
Morgenmøde om ´BYGGERIET's NYE AKTØRER´
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Windows Presentation Foundation & XAML
Windows Presentation Foundation & XAMLWindows Presentation Foundation & XAML
Windows Presentation Foundation & XAML
 
Indigo dyeing
Indigo dyeingIndigo dyeing
Indigo dyeing
 
Sequence diagram
Sequence diagramSequence diagram
Sequence diagram
 
Allu Upendra Resume-CE
Allu Upendra Resume-CEAllu Upendra Resume-CE
Allu Upendra Resume-CE
 

Similar to Deeksha gopaliya

Similar to Deeksha gopaliya (20)

Loops In C++
Loops In C++Loops In C++
Loops In C++
 
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
 
Loops c++
Loops c++Loops c++
Loops c++
 
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
 
Programming
ProgrammingProgramming
Programming
 
python.pptx
python.pptxpython.pptx
python.pptx
 
Loops in c
Loops in cLoops in c
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
 
Java Repetiotion Statements
Java Repetiotion StatementsJava Repetiotion Statements
Java Repetiotion Statements
 
Loops in c++
Loops in c++Loops in c++
Loops in c++
 
loops and iteration.docx
loops and iteration.docxloops and iteration.docx
loops and iteration.docx
 
class interview demo
class interview demo class interview demo
class interview demo
 
python
pythonpython
python
 
Demo for Class.pptx
 Demo for Class.pptx Demo for Class.pptx
Demo for Class.pptx
 
R loops
R   loopsR   loops
R loops
 
What is loops? What is For loop?
What is loops? What is For loop?What is loops? What is For loop?
What is loops? What is For loop?
 
dizital pods session 5-loops.pptx
dizital pods session 5-loops.pptxdizital pods session 5-loops.pptx
dizital pods session 5-loops.pptx
 
Cpp loop types
Cpp loop typesCpp loop types
Cpp loop types
 
LOOPSFor LoopFor loop executes group of Java statements as long.pdf
LOOPSFor LoopFor loop executes group of Java statements as long.pdfLOOPSFor LoopFor loop executes group of Java statements as long.pdf
LOOPSFor LoopFor loop executes group of Java statements as long.pdf
 

Recently uploaded

Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 

Recently uploaded (20)

Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 

Deeksha gopaliya

  • 1.
  • 2. Made By :-Made By :- Deeksha GopaliyaDeeksha Gopaliya 1111thth ScienceScience COMPUTERCOMPUTER PROJECTPROJECT
  • 3.
  • 4. L O O P I N G EXIT
  • 5. LOOPSLOOPS FORFOR LOOPLOOPFORFOR LOOPLOOP DODO WHILEWHILE LOOPLOOP DODO WHILEWHILE LOOPLOOPWHILEWHILE LOOPLOOPWHILEWHILE LOOPLOOP
  • 6. PARTS OF A LOOP 1. Initialization Expression - Before entering in a loop , its control variables must be initialized. The initializations expression gives the loop variables their first value. 2. Test Expression - The test expression is the expression whose truth value decides whether the loop body will be executed or not. 3. Update Expression - The update expression change the values of loop variables. The update expression is executed ; at the end of the loop after loop body is executed. 4. The body of the Loop – The statements that are executed repeatedly as long as the condition is true ,form the body of loop.
  • 7. FOR LOOPFOR LOOP For Loop executes a sequence of statements multiple time and abbreviates the code that manages the loop variable. Syntax: for (initialization; condition; update expression) Body of the loop; Example: #include<iostream.h> output: void main( ) 1 { 2 for (int i=0; i<=5; i++) 3
  • 8. Functioning oF For Loop in c++  For loop is used when we don’t know in advance how many times the loop will times the loop will be executed .  The loop terminates as soon as the condition becomes false. EXIT
  • 9. WHILEWHILE LOOPLOOP While loopWhile loop is an entry-controlled loop. It repeats a statement or group of statements while a condition is true. It tests the condition before executing the loop. Syntax: initialization; while (condition) loop=body; updating expression; Example : #include<iostream.h> Output: void main( ) 1 { 2 int i=1 Initialization expression 3 while (i<=5) 4 cout<<“n”<<i; Body of loop 5 i++; Update expression }
  • 10. DO WHILE LOOPDO WHILE LOOP Do while LoopDo while Loop is a exit-controlled loop. It evaluates its text expression at the bottom of the loop after executing the loop body statements. Syntax: initialization; do { loop body; updating expression; }while (condition); Example: #include<iostream.h. Output: void main( ) 1 {int i=1 Initialization expression 2 do 3 { 4 cout<<“n”<<i; Body of loop 5 i++; Update expression 6 }while (i<=5)
  • 11. Comparison between while loop and do while loop  While loop test condition before executing the loop body whereas do while loop test condition after executing loop body.  While loop is a entry-controlled loop whereas do while loop is a exit-controlled loop.  While loop is preferred when we don’t want to execute the loop body even once in case the condition is false whereas do while loop is preferred when we want to
  • 12.
  • 13. Functioning of Nested Loop Example: #include<iostream.h> void main( ) { for( int i=1; i<=3; i++) { for( int j=1; j<=i; j++) { cout<<i; } cout<<“n”; } } Inner Loop Outer Loop Output: 11 1212 123123
  • 14. POWERPOINTPOWERPOINT PRESENTATIONPRESENTATION ONON LOOPINGLOOPING IN C++IN C++ Made By:-Made By:- Deeksha GopaliyaDeeksha Gopaliya