SlideShare a Scribd company logo
2
Most read
8
Most read
13
Most read
What is 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
types of loops and what is loop

More Related Content

PPTX
The Loops
PPTX
Loop(for, while, do while) condition Presentation
PPT
Function overloading(c++)
PPTX
Loops in C
PPTX
Looping (Computer programming and utilization)
PPT
RECURSION IN C
PPTX
Recursive Function
PPTX
Loops c++
The Loops
Loop(for, while, do while) condition Presentation
Function overloading(c++)
Loops in C
Looping (Computer programming and utilization)
RECURSION IN C
Recursive Function
Loops c++

What's hot (20)

PPT
History of c++
PPT
Strings
PPT
While loop
PPTX
C tokens
PPTX
Type casting in c programming
PPT
user defined function
PPTX
Printf and scanf
PPTX
If else statement in c++
PDF
Operator Overloading in C++
PPTX
Control Flow Statements
PPTX
classes and objects in C++
PPTX
Loops in C Programming Language
PPTX
Function C programming
PPT
PPTX
Stack - Data Structure
PPTX
C++ language basic
PPTX
Programming in C Presentation upto FILE
PPTX
Exception Handling in object oriented programming using C++
PPTX
History of c++
Strings
While loop
C tokens
Type casting in c programming
user defined function
Printf and scanf
If else statement in c++
Operator Overloading in C++
Control Flow Statements
classes and objects in C++
Loops in C Programming Language
Function C programming
Stack - Data Structure
C++ language basic
Programming in C Presentation upto FILE
Exception Handling in object oriented programming using C++
Ad

Similar to types of loops and what is loop (20)

PPTX
What is to loop in c++
PDF
3. Flow Controls in C (Part II).pdf
PPTX
Lecture on Loop while loop for loop + program
PPTX
C Programming: Looping Statements in C Pgm
PPTX
PDF
Lecture 10
PPT
ch5.ppt
PPTX
Unit II.pptx
PDF
Loop and while Loop
PPTX
prt123.pptx
PDF
ReiBoot 10.11.0 Crack With Registration Code Free Do[2025]
PPTX
C language (Part 2)
PPTX
Loops in c
PDF
whileloop-161225171903.pdf
PPTX
10control statement in c#
PPTX
Decision Making & Loops
PPTX
Looping statements
PPT
8 statement level
PPTX
LOOPING STATEMENTS, JAVA,PROGRAMMING LOGIC
PPTX
Loop in C Properties & Applications
What is to loop in c++
3. Flow Controls in C (Part II).pdf
Lecture on Loop while loop for loop + program
C Programming: Looping Statements in C Pgm
Lecture 10
ch5.ppt
Unit II.pptx
Loop and while Loop
prt123.pptx
ReiBoot 10.11.0 Crack With Registration Code Free Do[2025]
C language (Part 2)
Loops in c
whileloop-161225171903.pdf
10control statement in c#
Decision Making & Loops
Looping statements
8 statement level
LOOPING STATEMENTS, JAVA,PROGRAMMING LOGIC
Loop in C Properties & Applications
Ad

Recently uploaded (20)

PPTX
GDM (1) (1).pptx small presentation for students
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Insiders guide to clinical Medicine.pdf
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Sports Quiz easy sports quiz sports quiz
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
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Cell Structure & Organelles in detailed.
PPTX
Institutional Correction lecture only . . .
GDM (1) (1).pptx small presentation for students
Module 4: Burden of Disease Tutorial Slides S2 2025
STATICS OF THE RIGID BODIES Hibbelers.pdf
O7-L3 Supply Chain Operations - ICLT Program
2.FourierTransform-ShortQuestionswithAnswers.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
RMMM.pdf make it easy to upload and study
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Insiders guide to clinical Medicine.pdf
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Supply Chain Operations Speaking Notes -ICLT Program
PPH.pptx obstetrics and gynecology in nursing
Sports Quiz easy sports quiz sports quiz
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
VCE English Exam - Section C Student Revision Booklet
Basic Mud Logging Guide for educational purpose
Renaissance Architecture: A Journey from Faith to Humanism
Cell Structure & Organelles in detailed.
Institutional Correction lecture only . . .

types of loops and what is loop

  • 1. What is 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