SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
PRESANTATION ON
“Looping control structure”
GUPTA HARSH
13ME030
Introduction of loop
• A loop is a programming structure that allows
an action to repeat until the program meets a
given condition.
• After each iteration of a loop, the loop checks
against a loop control expression to see if the
program met a the given condition. If it did,
the loop stops. If not, the loop moves on to
the next iteration.
CONTINUE…
• Loop: a control structure that repeats a group
of steps in a program
• C loop control statements
• Two types of control statement….. They are:-
Exit control loop and
Entry control loop
Exit Control loop
• In exit control loop, the
body is executed first and
then the condition is
checked.
• In exit control loop the
body is executed
at least once.
Entry Control loop
• In entry control loop,
the condition is checked
first and then body is
executed.
• In Entry control loop
the body is not
executed at all if the
condition is false.
Looping…
• ‘C’ language provides following looping
structures:-
1. WHILE
2. DO-WHILE
3. FOR
WHILE LOOP
– Of the three different loop structures offered in C, while-
loops are conceptually the simplest.
– Resembles if-statement, but does not have an else.
– Conceptually, keep executing the loop body again and
again till the condition is true.
– Loop terminates when the loop condition becomes false.
– Note that the truth of the loop condition is not checked
constantly between every statement in the loop body, but
only at the beginning of the loop, and then again between
the repetitions of the loop body
– Condition may be temporarily false during the loop, but
become true again before it is checked
Introduction to loops  cpu
DO-WHILE LOOP
– The second type of loop offered in C is the do-while.
– Clearly the least commonly used of the three: one famous
study of real world programs revealed that out of all loops
in them, only 1% are do-while.
– Do-while behaves exactly the same way as the while-loop,
but is guaranteed to execute its body at least once before
it starts looking at the loop condition.
– The possibility of executing the loop body zero times
does not exist, even if the condition is initially false
– do-while is most useful in situations where testing
the condition simply does not make any sense until
the loop body has been executed once
Introduction to loops  cpu
FOR LOOP
– The third type of loop structure in C is suitable for
the common task of iterating through the values of
a range of integers, one value at the time.
– For example, go through the numbers from 1 to 100.
– The for-loop header defines this range, and the loop
body contains the statements you execute for each
value.
– To define an integer range, you need to define three
things: where it begins (1), where it ends (100), and
the step size between the consecutive values of the
range (1)
CONTINUE…
– It is not a coincidence that the header of a for-loop
consists of three parts, for the three things that
define a range.
– We can still use while like in countdown, but using a
for-loop makes it clear that we are going through a
range.
– It is not a coincidence that the header of a for-loop
consists of three parts, for the three things that
define a range.
– We can still use while like in countdown, but using a
for-loop makes it clear that we are going through a
range.
Flowchart of FOR LOOP
for( initializing list;condition; updation)
BREAK STATEMENT
• Remember the break keyword that we used
to stop a switch statement from executing
more than one statement?
• break can also be used to exit an infinite
loop
• But it is almost always best to use a well-
written while loop.
CONTINUE STATEMENT
– Continue is a statement similar to break, but
instead of jumping out of the loop altogether, it
jumps to the next round of the loop, skipping the
rest of the body
– Most commonly used to skip some of the values
inside the range for which the loop doesn't need
to do anything
Introduction to loops  cpu

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
 
Java loops
Java loopsJava loops
Java loops
 
Programming loop
Programming loopProgramming loop
Programming loop
 
Java input Scanner
Java input Scanner Java input Scanner
Java input Scanner
 
Chap 6(decision making-looping)
Chap 6(decision making-looping)Chap 6(decision making-looping)
Chap 6(decision making-looping)
 
Java Repetiotion Statements
Java Repetiotion StatementsJava Repetiotion Statements
Java Repetiotion Statements
 
Loops c++
Loops c++Loops c++
Loops c++
 
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested LoopLoops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
Loops in C Programming | for Loop | do-while Loop | while Loop | Nested Loop
 
loops and iteration.docx
loops and iteration.docxloops and iteration.docx
loops and iteration.docx
 
Forloop
ForloopForloop
Forloop
 
While loops
While loopsWhile loops
While loops
 
The Loops
The LoopsThe Loops
The Loops
 
Decision making and looping
Decision making and loopingDecision making and looping
Decision making and looping
 
Loop (Computer programming and utilization)
Loop (Computer programming and utilization)Loop (Computer programming and utilization)
Loop (Computer programming and utilization)
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Looping in c++
Looping in c++Looping in c++
Looping in c++
 
Presentation on Loop(C Language) by Dheemaan Daash
Presentation on Loop(C Language)  by Dheemaan DaashPresentation on Loop(C Language)  by Dheemaan Daash
Presentation on Loop(C Language) by Dheemaan Daash
 
Loops
LoopsLoops
Loops
 
Looping
LoopingLooping
Looping
 
Control structures in c++
Control structures in c++Control structures in c++
Control structures in c++
 

Ähnlich wie Introduction to loops cpu

Ähnlich wie Introduction to loops cpu (20)

Cse lecture-7-c loop
Cse lecture-7-c loopCse lecture-7-c loop
Cse lecture-7-c loop
 
Loop in C Properties & Applications
Loop in C Properties & ApplicationsLoop in C Properties & Applications
Loop in C Properties & Applications
 
C language 2
C language 2C language 2
C language 2
 
Cpp loop types
Cpp loop typesCpp loop types
Cpp loop types
 
Loop
LoopLoop
Loop
 
Loops
LoopsLoops
Loops
 
C language (Part 2)
C language (Part 2)C language (Part 2)
C language (Part 2)
 
Loop structures
Loop structuresLoop structures
Loop structures
 
Chapter 9 - Loops in C++
Chapter 9 - Loops in C++Chapter 9 - Loops in C++
Chapter 9 - Loops in C++
 
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
 
Igdpd c21 loops
Igdpd c21 loopsIgdpd c21 loops
Igdpd c21 loops
 
Computer programming 2 Lesson 8
Computer programming 2  Lesson 8Computer programming 2  Lesson 8
Computer programming 2 Lesson 8
 
Control structures repetition
Control structures   repetitionControl structures   repetition
Control structures repetition
 
Loops In C++
Loops In C++Loops In C++
Loops In C++
 
whileloop-161225171903.pdf
whileloop-161225171903.pdfwhileloop-161225171903.pdf
whileloop-161225171903.pdf
 
While loop
While loopWhile loop
While loop
 
C Programming - Decision making, Looping
C  Programming - Decision making, LoopingC  Programming - Decision making, Looping
C Programming - Decision making, Looping
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
 
Loops in c++
Loops in c++Loops in c++
Loops in c++
 
Loops
LoopsLoops
Loops
 

Kürzlich hochgeladen

How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
UiPath Clipboard AI: "A TIME Magazine Best Invention of 2023 Unveiled"
UiPath Clipboard AI: "A TIME Magazine Best Invention of 2023 Unveiled"UiPath Clipboard AI: "A TIME Magazine Best Invention of 2023 Unveiled"
UiPath Clipboard AI: "A TIME Magazine Best Invention of 2023 Unveiled"DianaGray10
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
99.99% of Your Traces Are (Probably) Trash (SRECon NA 2024).pdf
99.99% of Your Traces  Are (Probably) Trash (SRECon NA 2024).pdf99.99% of Your Traces  Are (Probably) Trash (SRECon NA 2024).pdf
99.99% of Your Traces Are (Probably) Trash (SRECon NA 2024).pdfPaige Cruz
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
All in AI: LLM Landscape & RAG in 2024 with Mark Ryan (Google) & Jerry Liu (L...
All in AI: LLM Landscape & RAG in 2024 with Mark Ryan (Google) & Jerry Liu (L...All in AI: LLM Landscape & RAG in 2024 with Mark Ryan (Google) & Jerry Liu (L...
All in AI: LLM Landscape & RAG in 2024 with Mark Ryan (Google) & Jerry Liu (L...Daniel Zivkovic
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8DianaGray10
 
The Kubernetes Gateway API and its role in Cloud Native API Management
The Kubernetes Gateway API and its role in Cloud Native API ManagementThe Kubernetes Gateway API and its role in Cloud Native API Management
The Kubernetes Gateway API and its role in Cloud Native API ManagementNuwan Dias
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 

Kürzlich hochgeladen (20)

How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
UiPath Clipboard AI: "A TIME Magazine Best Invention of 2023 Unveiled"
UiPath Clipboard AI: "A TIME Magazine Best Invention of 2023 Unveiled"UiPath Clipboard AI: "A TIME Magazine Best Invention of 2023 Unveiled"
UiPath Clipboard AI: "A TIME Magazine Best Invention of 2023 Unveiled"
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
99.99% of Your Traces Are (Probably) Trash (SRECon NA 2024).pdf
99.99% of Your Traces  Are (Probably) Trash (SRECon NA 2024).pdf99.99% of Your Traces  Are (Probably) Trash (SRECon NA 2024).pdf
99.99% of Your Traces Are (Probably) Trash (SRECon NA 2024).pdf
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
All in AI: LLM Landscape & RAG in 2024 with Mark Ryan (Google) & Jerry Liu (L...
All in AI: LLM Landscape & RAG in 2024 with Mark Ryan (Google) & Jerry Liu (L...All in AI: LLM Landscape & RAG in 2024 with Mark Ryan (Google) & Jerry Liu (L...
All in AI: LLM Landscape & RAG in 2024 with Mark Ryan (Google) & Jerry Liu (L...
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8
 
The Kubernetes Gateway API and its role in Cloud Native API Management
The Kubernetes Gateway API and its role in Cloud Native API ManagementThe Kubernetes Gateway API and its role in Cloud Native API Management
The Kubernetes Gateway API and its role in Cloud Native API Management
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 

Introduction to loops cpu

  • 1. PRESANTATION ON “Looping control structure” GUPTA HARSH 13ME030
  • 2. Introduction of loop • A loop is a programming structure that allows an action to repeat until the program meets a given condition. • After each iteration of a loop, the loop checks against a loop control expression to see if the program met a the given condition. If it did, the loop stops. If not, the loop moves on to the next iteration.
  • 3. CONTINUE… • Loop: a control structure that repeats a group of steps in a program • C loop control statements • Two types of control statement….. They are:- Exit control loop and Entry control loop
  • 4. Exit Control loop • In exit control loop, the body is executed first and then the condition is checked. • In exit control loop the body is executed at least once.
  • 5. Entry Control loop • In entry control loop, the condition is checked first and then body is executed. • In Entry control loop the body is not executed at all if the condition is false.
  • 6. Looping… • ‘C’ language provides following looping structures:- 1. WHILE 2. DO-WHILE 3. FOR
  • 7. WHILE LOOP – Of the three different loop structures offered in C, while- loops are conceptually the simplest. – Resembles if-statement, but does not have an else. – Conceptually, keep executing the loop body again and again till the condition is true. – Loop terminates when the loop condition becomes false. – Note that the truth of the loop condition is not checked constantly between every statement in the loop body, but only at the beginning of the loop, and then again between the repetitions of the loop body – Condition may be temporarily false during the loop, but become true again before it is checked
  • 9. DO-WHILE LOOP – The second type of loop offered in C is the do-while. – Clearly the least commonly used of the three: one famous study of real world programs revealed that out of all loops in them, only 1% are do-while. – Do-while behaves exactly the same way as the while-loop, but is guaranteed to execute its body at least once before it starts looking at the loop condition. – The possibility of executing the loop body zero times does not exist, even if the condition is initially false – do-while is most useful in situations where testing the condition simply does not make any sense until the loop body has been executed once
  • 11. FOR LOOP – The third type of loop structure in C is suitable for the common task of iterating through the values of a range of integers, one value at the time. – For example, go through the numbers from 1 to 100. – The for-loop header defines this range, and the loop body contains the statements you execute for each value. – To define an integer range, you need to define three things: where it begins (1), where it ends (100), and the step size between the consecutive values of the range (1)
  • 12. CONTINUE… – It is not a coincidence that the header of a for-loop consists of three parts, for the three things that define a range. – We can still use while like in countdown, but using a for-loop makes it clear that we are going through a range. – It is not a coincidence that the header of a for-loop consists of three parts, for the three things that define a range. – We can still use while like in countdown, but using a for-loop makes it clear that we are going through a range.
  • 13. Flowchart of FOR LOOP for( initializing list;condition; updation)
  • 14. BREAK STATEMENT • Remember the break keyword that we used to stop a switch statement from executing more than one statement? • break can also be used to exit an infinite loop • But it is almost always best to use a well- written while loop.
  • 15. CONTINUE STATEMENT – Continue is a statement similar to break, but instead of jumping out of the loop altogether, it jumps to the next round of the loop, skipping the rest of the body – Most commonly used to skip some of the values inside the range for which the loop doesn't need to do anything