SlideShare a Scribd company logo
Topic : While , For , Do-While Loop
Guided By :
Branch : Batch :
Name ENROLLMENT NO.
Abhishek Chokshi 140120109005
Raj Shah
Kaveesh Raval
140120109054
140120109016
 Repetition statements allow us to execute a
statement multiple times
 Often they are referred to as loops
 Like conditional statements, they are
controlled by boolean expressions
 There are three kinds of repetition
statements:
 The syntax of while statement in C:
while (loop repetition condition)
statement
 Loop repetition condition is the condition
which controls the loop.
 The statement is repeated as long as the loop
repetition condition is true.
 A loop is called an infinite loop if the loop
repetition condition is always true.
Logical expression that determines
whether the action isto be executed
while ( Expression) Action
Action to be iteratively
performed until logical
expression isfalse
 A while statement has the following syntax:
while ( condition ){
statement;
}
• If the condition is true, the statement is executed
• Then the condition is evaluated again, and if it is still true, the
statement is executed again
• The statement is executed repeatedly until the condition becomes
false
statement
true false
condition
evaluated
 An example of a while statement:
int count = 1;
while (count <= 5){
System.out.println (count);
count++;
}
• If the condition of a while loop is false initially, the statement is
never executed
• Therefore, the body of a while loop will execute zero or more times
 The syntax of the do-while statement in
C:
do
statement
while (loop repetition condition);
 The statement is first executed.
 If the loop repetition condition is
satisfied, the statement is repeated else,
the repetition of the loop is stopped.
 Syntax
do Action
while
(Expression)
 Semantics
◦ Execute Action
◦ If Expression is true
then execute Action
again
◦ Repeat this process
until Expression
evaluates to false
 Action is either a
single statement or a
group of statements
within curly braces
Action
true
false
Expression
true
condition
evaluated
statement
false
do {
statement-1;
statement-2;
……
statement-k;
} while(condition);
Initialize
Statement-1
Statement-2
Statement-k
Is condition
TRUE?
N
Y
/* Find an even number input */
do{
printf(“Enter a value:n”);
scanf(“%d”,&num);
}while(num%2!=0)
printf(“n%d”,num);
This loop will repeat if the user inputs
odd number.
 The syntax of for statement in C:
for (initialization expression;
loop repetition condition;
update expression)
statement
 The initialization expression set the initial
value of the loop control variable.
 The loop repetition condition test the value of
the loop control variable.
 The update expression update the loop
control variable.
 A for statement has the following syntax:
for ( initialization ; condition ; increment ){
statement;
}
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
statement
true
condition
evaluated
false
increment
initialization
 A for loop is functionally equivalent to the
following while loop structure:
initialization;
while ( condition ){
statement;
increment;
}
 An example of a for loop:
for (int count=1; count <= 5; count++){
System.out.println (count);
}
• The initialization section can be used to declare a variable
• Like a while loop, the condition of a for loop is tested prior to
executing the loop body
• Therefore, the body of a for loop will execute zero or more times
 The increment section can perform any
calculation
• A for loop is well suited for executing statements a specific
number of times that can be calculated or determined in advance
for (int num=100; num > 0; num -= 5){
System.out.println (num);
}
 Each expression in the header of a for loop is
optional
 If the initialization is left out, no initialization is
performed
 If the condition is left out, it is always considered
to be true, and therefore creates an infinite loop
◦ We usually call this a “forever loop”
 If the increment is left out, no increment
operation is performed
 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
While , For , Do-While Loop

More Related Content

What's hot

Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
Niloy Saha
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
Sathish Narayanan
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
Tarun Sharma
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in CJeya Lakshmi
 
Forloop
ForloopForloop
Forloop
Dipen Vasoya
 
Conditional statement c++
Conditional statement c++Conditional statement c++
Conditional statement c++
amber chaudary
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
Python Control structures
Python Control structuresPython Control structures
Python Control structures
Siddique Ibrahim
 
Loops in C
Loops in CLoops in C
Loops in C
Kamal Acharya
 
C if else
C if elseC if else
C if else
Ritwik Das
 
If statements in c programming
If statements in c programmingIf statements in c programming
If statements in c programming
Archana Gopinath
 
Control structure C++
Control structure C++Control structure C++
Control structure C++
Anil Kumar
 
Jumping statements
Jumping statementsJumping statements
Jumping statementsSuneel Dogra
 
Operators in java
Operators in javaOperators in java
Operators in java
Then Murugeshwari
 
Presentation on C Switch Case Statements
Presentation on C Switch Case StatementsPresentation on C Switch Case Statements
Presentation on C Switch Case Statements
Dipesh Pandey
 
Branching statements
Branching statementsBranching statements
Branching statements
ArunMK17
 
Control statements
Control statementsControl statements
Control statements
Kanwalpreet Kaur
 
Array in c
Array in cArray in c
Array in c
Ravi Gelani
 

What's hot (20)

Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
 
Forloop
ForloopForloop
Forloop
 
Conditional statement c++
Conditional statement c++Conditional statement c++
Conditional statement c++
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
 
Loops in c
Loops in cLoops in c
Loops in c
 
Python Control structures
Python Control structuresPython Control structures
Python Control structures
 
Loops in C
Loops in CLoops in C
Loops in C
 
C if else
C if elseC if else
C if else
 
If statements in c programming
If statements in c programmingIf statements in c programming
If statements in c programming
 
Control structure C++
Control structure C++Control structure C++
Control structure C++
 
Jumping statements
Jumping statementsJumping statements
Jumping statements
 
Break and continue
Break and continueBreak and continue
Break and continue
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Presentation on C Switch Case Statements
Presentation on C Switch Case StatementsPresentation on C Switch Case Statements
Presentation on C Switch Case Statements
 
Branching statements
Branching statementsBranching statements
Branching statements
 
Control statements
Control statementsControl statements
Control statements
 
Array in c
Array in cArray in c
Array in c
 

Similar to While , For , Do-While Loop

Programming loop
Programming loopProgramming loop
Programming loop
University of Potsdam
 
Java Repetiotion Statements
Java Repetiotion StatementsJava Repetiotion Statements
Java Repetiotion Statements
Huda Alameen
 
Looping statements
Looping statementsLooping statements
Looping statements
AbhishekMondal42
 
loops and iteration.docx
loops and iteration.docxloops and iteration.docx
loops and iteration.docx
JavvajiVenkat
 
15-Loops.ppt
15-Loops.ppt15-Loops.ppt
15-Loops.ppt
harshsolankurephotos
 
Visula C# Programming Lecture 4
Visula C# Programming Lecture 4Visula C# Programming Lecture 4
Visula C# Programming Lecture 4
Abou Bakr Ashraf
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
CHANDAN KUMAR
 
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
Sowmya Jyothi
 
Loops in c++
Loops in c++Loops in c++
Loops in c++
Rebin Daho
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
TANUJ ⠀
 
Control statements anil
Control statements anilControl statements anil
Control statements anil
Anil Dutt
 
presentation on powerpoint template.pptx
presentation on powerpoint template.pptxpresentation on powerpoint template.pptx
presentation on powerpoint template.pptx
farantouqeer8
 
whileloop-161225171903.pdf
whileloop-161225171903.pdfwhileloop-161225171903.pdf
whileloop-161225171903.pdf
BasirKhan21
 
Loop and while Loop
Loop and while LoopLoop and while Loop
Loop and while Loop
JayBhavsar68
 
C language 2
C language 2C language 2
C language 2
Arafat Bin Reza
 
Loops and iteration.docx
Loops and iteration.docxLoops and iteration.docx
Loops and iteration.docx
NkurikiyimanaGodefre
 
C++ chapter 4
C++ chapter 4C++ chapter 4
C++ chapter 4
SHRIRANG PINJARKAR
 
Loops in c
Loops in cLoops in c
Loops in c
RekhaBudhwar
 
Programming Fundamentals in C++ structures
Programming Fundamentals in  C++ structuresProgramming Fundamentals in  C++ structures
Programming Fundamentals in C++ structures
ayshasafdarwaada
 

Similar to While , For , Do-While Loop (20)

Programming loop
Programming loopProgramming loop
Programming loop
 
Java Repetiotion Statements
Java Repetiotion StatementsJava Repetiotion Statements
Java Repetiotion Statements
 
Looping statements
Looping statementsLooping statements
Looping statements
 
loops and iteration.docx
loops and iteration.docxloops and iteration.docx
loops and iteration.docx
 
15-Loops.ppt
15-Loops.ppt15-Loops.ppt
15-Loops.ppt
 
Visula C# Programming Lecture 4
Visula C# Programming Lecture 4Visula C# Programming Lecture 4
Visula C# Programming Lecture 4
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
 
M C6java6
M C6java6M C6java6
M C6java6
 
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
 
Loops in c++
Loops in c++Loops in c++
Loops in c++
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
 
Control statements anil
Control statements anilControl statements anil
Control statements anil
 
presentation on powerpoint template.pptx
presentation on powerpoint template.pptxpresentation on powerpoint template.pptx
presentation on powerpoint template.pptx
 
whileloop-161225171903.pdf
whileloop-161225171903.pdfwhileloop-161225171903.pdf
whileloop-161225171903.pdf
 
Loop and while Loop
Loop and while LoopLoop and while Loop
Loop and while Loop
 
C language 2
C language 2C language 2
C language 2
 
Loops and iteration.docx
Loops and iteration.docxLoops and iteration.docx
Loops and iteration.docx
 
C++ chapter 4
C++ chapter 4C++ chapter 4
C++ chapter 4
 
Loops in c
Loops in cLoops in c
Loops in c
 
Programming Fundamentals in C++ structures
Programming Fundamentals in  C++ structuresProgramming Fundamentals in  C++ structures
Programming Fundamentals in C++ structures
 

More from Abhishek Choksi

Industrial Instrumentation (2170913) (Variable Inductance & Capacitance Tran...
Industrial Instrumentation (2170913)  (Variable Inductance & Capacitance Tran...Industrial Instrumentation (2170913)  (Variable Inductance & Capacitance Tran...
Industrial Instrumentation (2170913) (Variable Inductance & Capacitance Tran...
Abhishek Choksi
 
Switch Gear & Protection (2170908) (Generator Protection)
Switch Gear & Protection (2170908) (Generator Protection)Switch Gear & Protection (2170908) (Generator Protection)
Switch Gear & Protection (2170908) (Generator Protection)
Abhishek Choksi
 
Design of Magnetic Circuit for Synchronous Machine
Design of Magnetic Circuit for Synchronous MachineDesign of Magnetic Circuit for Synchronous Machine
Design of Magnetic Circuit for Synchronous Machine
Abhishek Choksi
 
Inter Connected Power System (2170901)
Inter Connected Power System (2170901)Inter Connected Power System (2170901)
Inter Connected Power System (2170901)
Abhishek Choksi
 
Third harmonic pwm
Third harmonic pwmThird harmonic pwm
Third harmonic pwm
Abhishek Choksi
 
Electric welding
Electric weldingElectric welding
Electric welding
Abhishek Choksi
 
Closed loop speed control
Closed loop speed controlClosed loop speed control
Closed loop speed control
Abhishek Choksi
 
Synthesis of unsymmetrical phasors from their symmetrical components
Synthesis of unsymmetrical phasors from their symmetrical componentsSynthesis of unsymmetrical phasors from their symmetrical components
Synthesis of unsymmetrical phasors from their symmetrical components
Abhishek Choksi
 
Design of lv winding
Design  of  lv  windingDesign  of  lv  winding
Design of lv winding
Abhishek Choksi
 
Measurement of hvac (High Voltage Engineering )
Measurement  of  hvac (High Voltage Engineering )Measurement  of  hvac (High Voltage Engineering )
Measurement of hvac (High Voltage Engineering )
Abhishek Choksi
 
Supply system (Electrical Power System)
Supply system (Electrical Power System)Supply system (Electrical Power System)
Supply system (Electrical Power System)
Abhishek Choksi
 
Design of dc armature winding
Design of dc armature windingDesign of dc armature winding
Design of dc armature winding
Abhishek Choksi
 
8051 microcontroller and it’s interface
8051 microcontroller and it’s interface8051 microcontroller and it’s interface
8051 microcontroller and it’s interface
Abhishek Choksi
 
Principle of regenerative braking and chopper configuration
Principle of regenerative braking and chopper configurationPrinciple of regenerative braking and chopper configuration
Principle of regenerative braking and chopper configuration
Abhishek Choksi
 
Root locus
Root locus Root locus
Root locus
Abhishek Choksi
 
Web application attack and audit framework (w3af)
Web application attack and audit framework (w3af)Web application attack and audit framework (w3af)
Web application attack and audit framework (w3af)
Abhishek Choksi
 
Discrete Fourier Transform
Discrete Fourier TransformDiscrete Fourier Transform
Discrete Fourier Transform
Abhishek Choksi
 
K - Map
  K - Map    K - Map
K - Map
Abhishek Choksi
 
Blue led
Blue ledBlue led
Blue led
Abhishek Choksi
 
Mars orbiter mission
Mars orbiter missionMars orbiter mission
Mars orbiter mission
Abhishek Choksi
 

More from Abhishek Choksi (20)

Industrial Instrumentation (2170913) (Variable Inductance & Capacitance Tran...
Industrial Instrumentation (2170913)  (Variable Inductance & Capacitance Tran...Industrial Instrumentation (2170913)  (Variable Inductance & Capacitance Tran...
Industrial Instrumentation (2170913) (Variable Inductance & Capacitance Tran...
 
Switch Gear & Protection (2170908) (Generator Protection)
Switch Gear & Protection (2170908) (Generator Protection)Switch Gear & Protection (2170908) (Generator Protection)
Switch Gear & Protection (2170908) (Generator Protection)
 
Design of Magnetic Circuit for Synchronous Machine
Design of Magnetic Circuit for Synchronous MachineDesign of Magnetic Circuit for Synchronous Machine
Design of Magnetic Circuit for Synchronous Machine
 
Inter Connected Power System (2170901)
Inter Connected Power System (2170901)Inter Connected Power System (2170901)
Inter Connected Power System (2170901)
 
Third harmonic pwm
Third harmonic pwmThird harmonic pwm
Third harmonic pwm
 
Electric welding
Electric weldingElectric welding
Electric welding
 
Closed loop speed control
Closed loop speed controlClosed loop speed control
Closed loop speed control
 
Synthesis of unsymmetrical phasors from their symmetrical components
Synthesis of unsymmetrical phasors from their symmetrical componentsSynthesis of unsymmetrical phasors from their symmetrical components
Synthesis of unsymmetrical phasors from their symmetrical components
 
Design of lv winding
Design  of  lv  windingDesign  of  lv  winding
Design of lv winding
 
Measurement of hvac (High Voltage Engineering )
Measurement  of  hvac (High Voltage Engineering )Measurement  of  hvac (High Voltage Engineering )
Measurement of hvac (High Voltage Engineering )
 
Supply system (Electrical Power System)
Supply system (Electrical Power System)Supply system (Electrical Power System)
Supply system (Electrical Power System)
 
Design of dc armature winding
Design of dc armature windingDesign of dc armature winding
Design of dc armature winding
 
8051 microcontroller and it’s interface
8051 microcontroller and it’s interface8051 microcontroller and it’s interface
8051 microcontroller and it’s interface
 
Principle of regenerative braking and chopper configuration
Principle of regenerative braking and chopper configurationPrinciple of regenerative braking and chopper configuration
Principle of regenerative braking and chopper configuration
 
Root locus
Root locus Root locus
Root locus
 
Web application attack and audit framework (w3af)
Web application attack and audit framework (w3af)Web application attack and audit framework (w3af)
Web application attack and audit framework (w3af)
 
Discrete Fourier Transform
Discrete Fourier TransformDiscrete Fourier Transform
Discrete Fourier Transform
 
K - Map
  K - Map    K - Map
K - Map
 
Blue led
Blue ledBlue led
Blue led
 
Mars orbiter mission
Mars orbiter missionMars orbiter mission
Mars orbiter mission
 

Recently uploaded

Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
abh.arya
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
Kamal Acharya
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 

Recently uploaded (20)

Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 

While , For , Do-While Loop

  • 1. Topic : While , For , Do-While Loop Guided By : Branch : Batch :
  • 2. Name ENROLLMENT NO. Abhishek Chokshi 140120109005 Raj Shah Kaveesh Raval 140120109054 140120109016
  • 3.  Repetition statements allow us to execute a statement multiple times  Often they are referred to as loops  Like conditional statements, they are controlled by boolean expressions  There are three kinds of repetition statements:
  • 4.  The syntax of while statement in C: while (loop repetition condition) statement  Loop repetition condition is the condition which controls the loop.  The statement is repeated as long as the loop repetition condition is true.  A loop is called an infinite loop if the loop repetition condition is always true.
  • 5. Logical expression that determines whether the action isto be executed while ( Expression) Action Action to be iteratively performed until logical expression isfalse
  • 6.  A while statement has the following syntax: while ( condition ){ statement; } • If the condition is true, the statement is executed • Then the condition is evaluated again, and if it is still true, the statement is executed again • The statement is executed repeatedly until the condition becomes false
  • 8.  An example of a while statement: int count = 1; while (count <= 5){ System.out.println (count); count++; } • If the condition of a while loop is false initially, the statement is never executed • Therefore, the body of a while loop will execute zero or more times
  • 9.
  • 10.  The syntax of the do-while statement in C: do statement while (loop repetition condition);  The statement is first executed.  If the loop repetition condition is satisfied, the statement is repeated else, the repetition of the loop is stopped.
  • 11.  Syntax do Action while (Expression)  Semantics ◦ Execute Action ◦ If Expression is true then execute Action again ◦ Repeat this process until Expression evaluates to false  Action is either a single statement or a group of statements within curly braces Action true false Expression
  • 15. /* Find an even number input */ do{ printf(“Enter a value:n”); scanf(“%d”,&num); }while(num%2!=0) printf(“n%d”,num); This loop will repeat if the user inputs odd number.
  • 16.  The syntax of for statement in C: for (initialization expression; loop repetition condition; update expression) statement  The initialization expression set the initial value of the loop control variable.  The loop repetition condition test the value of the loop control variable.  The update expression update the loop control variable.
  • 17.  A for statement has the following syntax: for ( initialization ; condition ; increment ){ statement; } 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
  • 19.  A for loop is functionally equivalent to the following while loop structure: initialization; while ( condition ){ statement; increment; }
  • 20.  An example of a for loop: for (int count=1; count <= 5; count++){ System.out.println (count); } • The initialization section can be used to declare a variable • Like a while loop, the condition of a for loop is tested prior to executing the loop body • Therefore, the body of a for loop will execute zero or more times
  • 21.  The increment section can perform any calculation • A for loop is well suited for executing statements a specific number of times that can be calculated or determined in advance for (int num=100; num > 0; num -= 5){ System.out.println (num); }
  • 22.  Each expression in the header of a for loop is optional  If the initialization is left out, no initialization is performed  If the condition is left out, it is always considered to be true, and therefore creates an infinite loop ◦ We usually call this a “forever loop”  If the increment is left out, no increment operation is performed
  • 23.  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