SlideShare a Scribd company logo
1 of 13
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
LOOPLOOP
WHILEWHILE
LOOPLOOP
WHILEWHILE
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 3
while (i<=5) 4
cout<<“n”<<i; 5
i++;
}
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 2
do 3
{ 4
cout<<“n”<<i; 5
i++; 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

What's hot (20)

Loops in c++ programming language
Loops in c++ programming language Loops in c++ programming language
Loops in c++ programming language
 
Conditional statement
Conditional statementConditional statement
Conditional statement
 
Forloop
ForloopForloop
Forloop
 
Control statements
Control statementsControl statements
Control statements
 
Break and continue
Break and continueBreak and continue
Break and continue
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Loops in c
Loops in cLoops in c
Loops in c
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
 
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
 
Inline Functions and Default arguments
Inline Functions and Default argumentsInline Functions and Default arguments
Inline Functions and Default arguments
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
Call by value or call by reference in C++
Call by value or call by reference in C++Call by value or call by reference in C++
Call by value or call by reference in C++
 
While loop
While loopWhile loop
While loop
 
What is to loop in c++
What is to loop in c++What is to loop in c++
What is to loop in c++
 
Final keyword
Final keywordFinal keyword
Final keyword
 
Loops c++
Loops c++Loops c++
Loops c++
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Recursion
RecursionRecursion
Recursion
 

Viewers also liked

Viewers also liked (13)

C++loop statements
C++loop statementsC++loop statements
C++loop statements
 
Loop c++
Loop c++Loop c++
Loop c++
 
Looping in c++
Looping in c++Looping in c++
Looping in c++
 
Cpp loop types
Cpp loop typesCpp loop types
Cpp loop types
 
Chapter 7 - The Repetition Structure
Chapter 7 - The Repetition StructureChapter 7 - The Repetition Structure
Chapter 7 - The Repetition Structure
 
[C++]3 loop statement
[C++]3 loop statement[C++]3 loop statement
[C++]3 loop statement
 
45 Days C++ Programming Language Training in Ambala
45 Days C++ Programming Language Training in Ambala45 Days C++ Programming Language Training in Ambala
45 Days C++ Programming Language Training in Ambala
 
Loops
LoopsLoops
Loops
 
C++ loop
C++ loop C++ loop
C++ loop
 
Control Statements, Array, Pointer, Structures
Control Statements, Array, Pointer, StructuresControl Statements, Array, Pointer, Structures
Control Statements, Array, Pointer, Structures
 
Creating HTML Pages
Creating HTML PagesCreating HTML Pages
Creating HTML Pages
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 

Similar to Looping in c++

PRESENTATION ON FOR LOOP
PRESENTATION  ON FOR LOOPPRESENTATION  ON FOR LOOP
PRESENTATION ON FOR LOOP
Farooq Joyia
 
Chapter 9 - Loops in C++
Chapter 9 - Loops in C++Chapter 9 - Loops in C++
Chapter 9 - Loops in C++
Deepak Singh
 

Similar to Looping in c++ (20)

Deeksha gopaliya
Deeksha gopaliyaDeeksha gopaliya
Deeksha gopaliya
 
Loops In C++
Loops In C++Loops In C++
Loops In C++
 
Loop structures
Loop structuresLoop structures
Loop structures
 
Loop
LoopLoop
Loop
 
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
 
Computer programming 2 Lesson 8
Computer programming 2  Lesson 8Computer programming 2  Lesson 8
Computer programming 2 Lesson 8
 
Loops in c
Loops in cLoops in c
Loops in 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
 
Loop in C Properties & Applications
Loop in C Properties & ApplicationsLoop in C Properties & Applications
Loop in C Properties & Applications
 
Programming
ProgrammingProgramming
Programming
 
python.pptx
python.pptxpython.pptx
python.pptx
 
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
 
PRESENTATION ON FOR LOOP
PRESENTATION  ON FOR LOOPPRESENTATION  ON FOR LOOP
PRESENTATION ON FOR LOOP
 
loops and iteration.docx
loops and iteration.docxloops and iteration.docx
loops and iteration.docx
 
Loops
LoopsLoops
Loops
 
Chapter 9 - Loops in C++
Chapter 9 - Loops in C++Chapter 9 - Loops in C++
Chapter 9 - Loops in C++
 
loops in C ppt.pdf
loops in C ppt.pdfloops in C ppt.pdf
loops in C ppt.pdf
 
dizital pods session 5-loops.pptx
dizital pods session 5-loops.pptxdizital pods session 5-loops.pptx
dizital pods session 5-loops.pptx
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 

Looping in c++

  • 1. Made By :-Made By :- Deeksha GopaliyaDeeksha Gopaliya 1111thth ScienceScience COMPUTERCOMPUTER PROJECTPROJECT
  • 2.
  • 3. L O O P I N G EXIT
  • 4. LOOPSLOOPS FORFOR LOOPLOOPFORFOR LOOPLOOP DODO WHILEWHILE LOOPLOOP DODO WHILEWHILE LOOPLOOP WHILEWHILE LOOPLOOP WHILEWHILE LOOPLOOP
  • 5. 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.
  • 6. 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
  • 7. 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
  • 8. 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 3 while (i<=5) 4 cout<<“n”<<i; 5 i++; }
  • 9. 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 2 do 3 { 4 cout<<“n”<<i; 5 i++; 6 }while (i<=5)
  • 10. 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
  • 11.
  • 12. 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
  • 13. POWERPOINTPOWERPOINT PRESENTATIONPRESENTATION ONON LOOPINGLOOPING IN C++IN C++ Made By:-Made By:- Deeksha GopaliyaDeeksha Gopaliya