SlideShare a Scribd company logo
WHAT IS TO LOOP? AND TYPE OF LOOP
THE UNIVERSITY OF LAHORE PAKPATTAN CAMPUS
DEFINITION OF LOOP
• Loops are used in programming to repeat a specific block of code until some
end condition is met.
There are three type of loops in C++ programming
• for loop
• while loop
• Do while loop
FOR LOOP SYNTAX IN C++
for(initializationStatement; testExpression; updateStatement)
{
// codes
}
HOW FOR LOOP WORKS?
1.The initialization statement is executed only once at the beginning.
2.Then, the test expression is evaluated.
3.If the test expression is false, for loop is terminated. But if the test
expression is true, codes inside body of for loop is executed and update
expression is updated.
4.Again, the test expression is evaluated and this process repeats until the
test expression is false.
FLOWCHART OF FOR LOOP IN C++
PROGRAM OF FOR LOOP IN C++
WHILE LOOP
THE UNIVERSITY OF LAHORE PAKPATTAN CAMPUS
WHILE LOOP SYNTAX IN C++
while (testExpression)
{
// codes
}
HOW WHILE LOOP WORKS?
•The while loop evaluates the test expression.
•If the test expression is true, codes inside the body of while loop is evaluated.
•Then, the test expression is evaluated again. This process goes on until the test
expression is false.
•When the test expression is false, while loop is terminated.
FLOWCHART OF WHILE LOOP
C++ WHILE LOOP EXAMPLE
DO WHILE LOOP
THE UNIVERSITY OF LAHORE PAKPATTAN CAMPUS
DO WHILE LOOP SYNTAX IN C++
Do
{
// codes;
}
while (testExpression);
HOW DO...WHILE LOOP WORKS?
•The codes inside the body of loop is executed at least once. Then, only the
test expression is checked.
•If the test expression is true, the body of loop is executed. This process
continues until the test expression becomes false.
•When the test expression is false, do...while loop is terminated.
FLOWCHART OF DO WHILE LOOP
C++ WHILE LOOP EXAMPLE
ANY QUESTIONS
What is to loop in c++

More Related Content

PPTX
Method overloading
PPTX
Presentation on software construction
PPTX
Push down automata
PPTX
Boolean and conditional logic in Python
PPTX
PART 7 - Python Tutorial | Dictionaries In Python With Examples
PPTX
PART 1 - Python Tutorial | Variables and Data Types in Python
PPTX
Switch Case in C Programming
PPT
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...
Method overloading
Presentation on software construction
Push down automata
Boolean and conditional logic in Python
PART 7 - Python Tutorial | Dictionaries In Python With Examples
PART 1 - Python Tutorial | Variables and Data Types in Python
Switch Case in C Programming
Polymorphism in c++ ppt (Powerpoint) | Polymorphism in c++ with example ppt |...

What's hot (20)

PPTX
While , For , Do-While Loop
PPTX
Templates in C++
PPT
Kleene's theorem
PPTX
Python variables and data types.pptx
PPTX
Principal source of optimization in compiler design
PPTX
Object oriented programming 6 oop with c++
PPTX
Procedural vs. object oriented programming
PPTX
Phases of Compiler
PPTX
Loops Basics
PPT
Functions in C++
PPTX
Part 2 - Python Tutorial | Introduction to Lists
PPTX
Strings in Java
PPTX
types of loops and what is loop
PPTX
Looping statement
PPTX
Unit 1 polynomial manipulation
PPTX
PART 3 - Python Tutorial | For Loop In Python With Examples
PPTX
Android Development with Kotlin course
DOC
Generalized transition graphs
PDF
Files and streams
While , For , Do-While Loop
Templates in C++
Kleene's theorem
Python variables and data types.pptx
Principal source of optimization in compiler design
Object oriented programming 6 oop with c++
Procedural vs. object oriented programming
Phases of Compiler
Loops Basics
Functions in C++
Part 2 - Python Tutorial | Introduction to Lists
Strings in Java
types of loops and what is loop
Looping statement
Unit 1 polynomial manipulation
PART 3 - Python Tutorial | For Loop In Python With Examples
Android Development with Kotlin course
Generalized transition graphs
Files and streams
Ad

Similar to What is to loop in c++ (20)

PDF
whileloop-161225171903.pdf
PPT
While loop
PPT
Deeksha gopaliya
PPTX
Loops c++
PPT
Looping in c++
PPT
Looping in c++
PDF
Loops in c++
PPTX
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
PDF
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
PPTX
LOOPS IN PROGRAMMING - Muqaddas Bin Tahir .pptx
PPTX
Lecture on Loop while loop for loop + program
PPTX
PDF
LOOPING_STATEMENT c++ pptx from bgctub university
PPTX
Cs1123 6 loops
PDF
3. Flow Controls in C (Part II).pdf
PPTX
C Programming: Looping Statements in C Pgm
PPTX
Lec7 - Loops updated.pptx
whileloop-161225171903.pdf
While loop
Deeksha gopaliya
Loops c++
Looping in c++
Looping in c++
Loops in c++
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
LOOPS IN PROGRAMMING - Muqaddas Bin Tahir .pptx
Lecture on Loop while loop for loop + program
LOOPING_STATEMENT c++ pptx from bgctub university
Cs1123 6 loops
3. Flow Controls in C (Part II).pdf
C Programming: Looping Statements in C Pgm
Lec7 - Loops updated.pptx
Ad

Recently uploaded (20)

PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Classroom Observation Tools for Teachers
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Pre independence Education in Inndia.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
master seminar digital applications in india
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
01-Introduction-to-Information-Management.pdf
PDF
RMMM.pdf make it easy to upload and study
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Classroom Observation Tools for Teachers
Microbial diseases, their pathogenesis and prophylaxis
STATICS OF THE RIGID BODIES Hibbelers.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
FourierSeries-QuestionsWithAnswers(Part-A).pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
2.FourierTransform-ShortQuestionswithAnswers.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Pre independence Education in Inndia.pdf
GDM (1) (1).pptx small presentation for students
Anesthesia in Laparoscopic Surgery in India
TR - Agricultural Crops Production NC III.pdf
master seminar digital applications in india
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
01-Introduction-to-Information-Management.pdf
RMMM.pdf make it easy to upload and study

What is to loop in c++

  • 1. WHAT IS TO LOOP? AND TYPE OF LOOP THE UNIVERSITY OF LAHORE PAKPATTAN CAMPUS
  • 2. DEFINITION OF LOOP • Loops are used in programming to repeat a specific block of code until some end condition is met. There are three type of loops in C++ programming • for loop • while loop • Do while loop
  • 3. FOR LOOP SYNTAX IN C++ for(initializationStatement; testExpression; updateStatement) { // codes }
  • 4. HOW FOR LOOP WORKS? 1.The initialization statement is executed only once at the beginning. 2.Then, the test expression is evaluated. 3.If the test expression is false, for loop is terminated. But if the test expression is true, codes inside body of for loop is executed and update expression is updated. 4.Again, the test expression is evaluated and this process repeats until the test expression is false.
  • 5. FLOWCHART OF FOR LOOP IN C++
  • 6. PROGRAM OF FOR LOOP IN C++
  • 7. WHILE LOOP THE UNIVERSITY OF LAHORE PAKPATTAN CAMPUS
  • 8. WHILE LOOP SYNTAX IN C++ while (testExpression) { // codes }
  • 9. HOW WHILE LOOP WORKS? •The while loop evaluates the test expression. •If the test expression is true, codes inside the body of while loop is evaluated. •Then, the test expression is evaluated again. This process goes on until the test expression is false. •When the test expression is false, while loop is terminated.
  • 11. C++ WHILE LOOP EXAMPLE
  • 12. DO WHILE LOOP THE UNIVERSITY OF LAHORE PAKPATTAN CAMPUS
  • 13. DO WHILE LOOP SYNTAX IN C++ Do { // codes; } while (testExpression);
  • 14. HOW DO...WHILE LOOP WORKS? •The codes inside the body of loop is executed at least once. Then, only the test expression is checked. •If the test expression is true, the body of loop is executed. This process continues until the test expression becomes false. •When the test expression is false, do...while loop is terminated.
  • 15. FLOWCHART OF DO WHILE LOOP
  • 16. C++ WHILE LOOP EXAMPLE