SlideShare a Scribd company logo
1 of 11
LOOPS
CONCEPT OF LOOPS AND FOR LOOP
ABOUT ME
Md. Emon Rana
Id : 20104009
Batch : Spring-20
Mobile : 019414562
Email : emonrana@gmail.com
1. What is loop
2. How it works
3. Parts of loop
4. Type of loop
* For Loop
5. Example
CONTENTS
WHAT IS LOOP
• The loop statements allow a set of instructions to be performed
repeatedly until a certain condition is fulfilled.
HOW IT WORKS
Running
A sequence of statement is executed
until a specified condition is true.
This sequence of statement to be
executed is kept inside the curly
braces {} known as loop body. After
every execution of loop body,
condition is checked, and if it is
found to be true the loop body is
executed again. When condition
check comes out to be false, the
loop body will not be executed.
Execute loop
Loop
Entry
False
Test
conditi
on
Out of
loop
True
PARTS OF LOOP
• Initialization Expression(s) : initialize(s) the loop variables in the
beginning of the loop.
• Test Expression : decides whether the loop will be executed (if
test expression is true) or not (if test expression is false).
• Increment/Decrement : This part increments or decrements the value of a variable
that is being checked
• The Body-of-the-Loop : contains statements to be executed
repeatedly.
For(Initialization; test expression;
increment/decrement)
{
body;
TYPE OF LOOP
There are various ways to use loops. Mainly usage among of
them are :
While
loop
Repeats a statement or group of statements until 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
loop
You can use one or more loop inside any another while, for or do..while
loop.
FOR LOOP
For-loop is a type of loop. For-loop is a control flow statement for specifying
iteration, which allows code to be executed repeatedly.
STRUCTURE OF FOR LOOP
For(Initialization; test expression; increment/decrement)
{
body;
}
The
initialization is
executed once
before the
loop begins
The statement is
executed until
the condition
becomes false
The increment portion
is executed at the end
of each iteration
EXAMPLE
#include <stdio.h>
int main() {
int i;
for (I = 1; I < 11; ++i)
{
printf("%d ", i);
}
return 0;
}
Output :
1 2 3 4 5 6 7 8 9 10
THE END
Thank you all for having patience during my presentation…

More Related Content

What's hot (20)

Looping (Computer programming and utilization)
Looping (Computer programming and utilization)Looping (Computer programming and utilization)
Looping (Computer programming and utilization)
 
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
 
Loops in c++ programming language
Loops in c++ programming language Loops in c++ programming language
Loops in c++ programming language
 
While loops
While loopsWhile loops
While loops
 
Looping in c++
Looping in c++Looping in c++
Looping in c++
 
Do...while loop structure
Do...while loop structureDo...while loop structure
Do...while loop structure
 
While loop
While loopWhile loop
While loop
 
Loops
LoopsLoops
Loops
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
 
Loops
LoopsLoops
Loops
 
Iteration Statement in C++
Iteration Statement in C++Iteration Statement in C++
Iteration Statement in C++
 
Nested loop in C language
Nested loop in C languageNested loop in C language
Nested loop in C language
 
Loops in c++
Loops in c++Loops in c++
Loops in c++
 
Cpp loop types
Cpp loop typesCpp loop types
Cpp loop types
 
Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)
 
3.looping(iteration statements)
3.looping(iteration statements)3.looping(iteration statements)
3.looping(iteration statements)
 
Deeksha gopaliya
Deeksha gopaliyaDeeksha gopaliya
Deeksha gopaliya
 
Looping and Switchcase BDCR
Looping and Switchcase BDCRLooping and Switchcase BDCR
Looping and Switchcase BDCR
 
Iteration
IterationIteration
Iteration
 
R loops
R   loopsR   loops
R loops
 

Similar to Loop

Similar to Loop (20)

Loops In C++
Loops In C++Loops In C++
Loops In C++
 
C language 2
C language 2C language 2
C language 2
 
Java Repetiotion Statements
Java Repetiotion StatementsJava Repetiotion Statements
Java Repetiotion Statements
 
Looping in c++
Looping in c++Looping in c++
Looping in c++
 
Loop structures
Loop structuresLoop structures
Loop structures
 
Cse lecture-7-c loop
Cse lecture-7-c loopCse lecture-7-c loop
Cse lecture-7-c loop
 
dizital pods session 5-loops.pptx
dizital pods session 5-loops.pptxdizital pods session 5-loops.pptx
dizital pods session 5-loops.pptx
 
loops and iteration.docx
loops and iteration.docxloops and iteration.docx
loops and iteration.docx
 
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?
 
Decision making and loop in C#
Decision making and loop in C#Decision making and loop in C#
Decision making and loop in C#
 
cpu.pdf
cpu.pdfcpu.pdf
cpu.pdf
 
STATEMENT’S AND LOOP’S
STATEMENT’S AND LOOP’SSTATEMENT’S AND LOOP’S
STATEMENT’S AND LOOP’S
 
Loop in C Properties & Applications
Loop in C Properties & ApplicationsLoop in C Properties & Applications
Loop in C Properties & Applications
 
Loops c++
Loops c++Loops c++
Loops c++
 
Introduction to loops cpu
Introduction to loops  cpuIntroduction to loops  cpu
Introduction to loops cpu
 
Computer programming 2 Lesson 8
Computer programming 2  Lesson 8Computer programming 2  Lesson 8
Computer programming 2 Lesson 8
 
Loop (Computer programming and utilization)
Loop (Computer programming and utilization)Loop (Computer programming and utilization)
Loop (Computer programming and utilization)
 
Loops in c
Loops in cLoops in c
Loops in c
 
python.pptx
python.pptxpython.pptx
python.pptx
 
Unit II chapter 4 Loops in C
Unit II chapter 4 Loops in CUnit II chapter 4 Loops in C
Unit II chapter 4 Loops in C
 

Recently uploaded

Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine 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
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
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
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
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
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
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
 
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
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 

Recently uploaded (20)

Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
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
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
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
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
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
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
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
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
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
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 

Loop

  • 1. LOOPS CONCEPT OF LOOPS AND FOR LOOP
  • 2. ABOUT ME Md. Emon Rana Id : 20104009 Batch : Spring-20 Mobile : 019414562 Email : emonrana@gmail.com
  • 3. 1. What is loop 2. How it works 3. Parts of loop 4. Type of loop * For Loop 5. Example CONTENTS
  • 4. WHAT IS LOOP • The loop statements allow a set of instructions to be performed repeatedly until a certain condition is fulfilled.
  • 5. HOW IT WORKS Running A sequence of statement is executed until a specified condition is true. This sequence of statement to be executed is kept inside the curly braces {} known as loop body. After every execution of loop body, condition is checked, and if it is found to be true the loop body is executed again. When condition check comes out to be false, the loop body will not be executed. Execute loop Loop Entry False Test conditi on Out of loop True
  • 6. PARTS OF LOOP • Initialization Expression(s) : initialize(s) the loop variables in the beginning of the loop. • Test Expression : decides whether the loop will be executed (if test expression is true) or not (if test expression is false). • Increment/Decrement : This part increments or decrements the value of a variable that is being checked • The Body-of-the-Loop : contains statements to be executed repeatedly. For(Initialization; test expression; increment/decrement) { body;
  • 7. TYPE OF LOOP There are various ways to use loops. Mainly usage among of them are : While loop Repeats a statement or group of statements until 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 loop You can use one or more loop inside any another while, for or do..while loop.
  • 8. FOR LOOP For-loop is a type of loop. For-loop is a control flow statement for specifying iteration, which allows code to be executed repeatedly.
  • 9. STRUCTURE OF FOR LOOP For(Initialization; test expression; increment/decrement) { body; } The initialization is executed once before the loop begins The statement is executed until the condition becomes false The increment portion is executed at the end of each iteration
  • 10. EXAMPLE #include <stdio.h> int main() { int i; for (I = 1; I < 11; ++i) { printf("%d ", i); } return 0; } Output : 1 2 3 4 5 6 7 8 9 10
  • 11. THE END Thank you all for having patience during my presentation…