SlideShare a Scribd company logo
7
Pretest Vs. Posttest
Pretest : Condition is tested before each iteration to check
if loops should occur.
Posttest : Condition is tested after each iteration to check
if loop should continue (at least a single iteration occurs).
Conditio
n
Evaluate
d
Statements
false
true Conditio
n
Evaluate
d
Statements
true
false
Most read
9
while Loop
 It has a loop condition only that is tested before each
iteration to decide whether to continue or terminate the
loop.
 The body of a while loop will execute zero or more
times
Syntax:
while (<condition>){
<statement/block>;
}
Most read
10
Example :
int i=0;
while(i<3){
printf(“Hellon”);
i++;
}
Output:
Hello
Hello
Hello
Conditio
n
Evaluate
d
Statements
true
false
Flow diagram
Most read
Prepared By
Mahantesh S. Devoor
Content
 Objective
 Introduction
Types of looping
while
do-while
for
 Assessment metric
Conclusion
References
Course Objective
 Understand the basic terminology used in computer
programming
 It stresses the strengths of C, which provide students with
the means of writing efficient, maintainable, and portable
code.
 write, compile and debug programs in C language.
 Increase the ability to learn new programming languages
OBJECTIVES
Topic Objective
 Understand the basics of looping.
 To use the while, do-while and for repetition statement to
execute statements in a program repeatedly.
INTRODUCTION
 Statements in a program are executed one after the other
ex: statement 1;
statement 2;
:
statement n;
 Sometimes, the user want to execute a set of statements
repeatedly.
 Loop statements are used to repeat the execution of
statement or blocks.
Iteration of a loop: the number of times the body of loop is
executed.
 Two types of loop structure are:
Pretest : Entry - controlled loop
Posttest : Exit – controlled loop
Pretest Vs. Posttest
Pretest : Condition is tested before each iteration to check
if loops should occur.
Posttest : Condition is tested after each iteration to check
if loop should continue (at least a single iteration occurs).
Conditio
n
Evaluate
d
Statements
false
true Conditio
n
Evaluate
d
Statements
true
false
TYPES OF LOOP
 while loop
 do-while loop
 for loop
while Loop
 It has a loop condition only that is tested before each
iteration to decide whether to continue or terminate the
loop.
 The body of a while loop will execute zero or more
times
Syntax:
while (<condition>){
<statement/block>;
}
Example :
int i=0;
while(i<3){
printf(“Hellon”);
i++;
}
Output:
Hello
Hello
Hello
Conditio
n
Evaluate
d
Statements
true
false
Flow diagram
do…while Loop
 Do while has a loop condition only that is tested after
each iteration to decide whether to continue with next
iteration or terminate the loop.
Syntax:
do{
<statement/block>;
}while(condition);
Example:
int i=0;
do{
Printf (“Hellon”);
i++;
} while (i<3);
Output:
Hello
Hello
Hello
Conditio
n
Evaluate
d
Statements
true
false
Flow diagram
for Loop
for loop has three parts:
 Initializer is executed at start of loop.
 Loop condition is tested before iteration to decide
whether to continue or terminate the loop.
 Increment is executed at the end of each loop iteration.
Syntax:
for( [initialize]; [condition]; [incrementor] )
{
<statement/block>;
}
Conditio
n
Evaluate
d
initialization
Statements
increament
true false
Flow diagram
Example:
for(i=0; i<3; i++)
{
printf(“Hellon”);
}
Output:
Hello
Hello
Hello
ASSESSMENT METRIC
 What is looping? List the types of looping.
 Explain the while loop with an example.
 Give the difference between while and do-while loops
 Explain the syntax of for loop with an example
 List out the difference between while and for loop. And also
explain the do-while loop.
CONCLUSION
 Importance of loops in any programming language is
immense, they allow us to reduce the number of lines in a
code, making our code more readable and efficient.
REFERENCES
[1]. E. Balaguruswamy, “Programming in ANSI C”, Third
edition, Tata McGraw Hill Publications, 2002.
[2]. P. B. Kotur, “Computer Concepts and C
programming”, Kindle Edition, Sapna Book House,
Bangalore, 2009.
Loops in C Programming Language

More Related Content

What's hot (20)

Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
programming9
 
Data types in C
Data types in CData types in C
Data types in C
Tarun Sharma
 
Presentation on C Switch Case Statements
Presentation on C Switch Case StatementsPresentation on C Switch Case Statements
Presentation on C Switch Case Statements
Dipesh Panday
 
C language ppt
C language pptC language ppt
C language ppt
Ğäùråv Júñêjå
 
C keywords and identifiers
C keywords and identifiersC keywords and identifiers
C keywords and identifiers
Akhileshwar Reddy Ankireddy
 
Loops c++
Loops c++Loops c++
Loops c++
Shivani Singh
 
Loops in c++ programming language
Loops in c++ programming language Loops in c++ programming language
Loops in c++ programming language
MUHAMMAD ALI student of IT at karakoram International university gilgit baltistan
 
String functions in C
String functions in CString functions in C
String functions in C
baabtra.com - No. 1 supplier of quality freshers
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
Harendra Singh
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
Abhishek Choksi
 
Unit 3. Input and Output
Unit 3. Input and OutputUnit 3. Input and Output
Unit 3. Input and Output
Ashim Lamichhane
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
C tokens
C tokensC tokens
C tokens
Manu1325
 
Array in c
Array in cArray in c
Array in c
Ravi Gelani
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
MANJUTRIPATHI7
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
Shaina Arora
 
Character set of c
Character set of cCharacter set of c
Character set of c
Chandrapriya Rediex
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
tanmaymodi4
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
Manoj Tyagi
 

Viewers also liked (20)

Videos indexing and retrieval using XML/XQuery
Videos indexing and retrieval using XML/XQueryVideos indexing and retrieval using XML/XQuery
Videos indexing and retrieval using XML/XQuery
Mahantesh Devoor
 
Business Model Designing (in Chinese)
Business Model Designing (in Chinese)Business Model Designing (in Chinese)
Business Model Designing (in Chinese)
McNairCenterHBU
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controls
vinay arora
 
Social media update
Social media updateSocial media update
Social media update
Element Productions
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
Haard Shah
 
Looping and Switchcase BDCR
Looping and Switchcase BDCRLooping and Switchcase BDCR
Looping and Switchcase BDCR
beriver
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
Leslie Samuel
 
Fundamentals of programming finals.ajang
Fundamentals of programming finals.ajangFundamentals of programming finals.ajang
Fundamentals of programming finals.ajang
Jaricka Angelyd Marquez
 
Unit 4a
Unit 4aUnit 4a
Unit 4a
Alanda Fuller
 
Looping in C
Looping in CLooping in C
Looping in C
Prabhu Govind
 
Parsing XML in J2ME
Parsing XML in J2MEParsing XML in J2ME
Parsing XML in J2ME
Rohan Chandane
 
Lecture3 ode (1) lamia
Lecture3 ode (1) lamiaLecture3 ode (1) lamia
Lecture3 ode (1) lamia
malkinh
 
Looping
LoopingLooping
Looping
Kulachi Hansraj Model School Ashok Vihar
 
Looping statement
Looping statementLooping statement
Looping statement
ilakkiya
 
SULTHAN's - C Programming Language notes
SULTHAN's - C Programming Language notesSULTHAN's - C Programming Language notes
SULTHAN's - C Programming Language notes
SULTHAN BASHA
 
Dia internacional de la mujer vanessa
Dia internacional de la mujer vanessaDia internacional de la mujer vanessa
Dia internacional de la mujer vanessa
16vanessa
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
Vivek Singh Chandel
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
MeoRamos
 
Creativity report
Creativity reportCreativity report
Creativity report
izzy ajzenszmidt
 
Business Storytelling y Pitch
Business Storytelling y PitchBusiness Storytelling y Pitch
Business Storytelling y Pitch
SolarAcademy_CIETUAI
 
Videos indexing and retrieval using XML/XQuery
Videos indexing and retrieval using XML/XQueryVideos indexing and retrieval using XML/XQuery
Videos indexing and retrieval using XML/XQuery
Mahantesh Devoor
 
Business Model Designing (in Chinese)
Business Model Designing (in Chinese)Business Model Designing (in Chinese)
Business Model Designing (in Chinese)
McNairCenterHBU
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controls
vinay arora
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
Haard Shah
 
Looping and Switchcase BDCR
Looping and Switchcase BDCRLooping and Switchcase BDCR
Looping and Switchcase BDCR
beriver
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
Leslie Samuel
 
Fundamentals of programming finals.ajang
Fundamentals of programming finals.ajangFundamentals of programming finals.ajang
Fundamentals of programming finals.ajang
Jaricka Angelyd Marquez
 
Lecture3 ode (1) lamia
Lecture3 ode (1) lamiaLecture3 ode (1) lamia
Lecture3 ode (1) lamia
malkinh
 
Looping statement
Looping statementLooping statement
Looping statement
ilakkiya
 
SULTHAN's - C Programming Language notes
SULTHAN's - C Programming Language notesSULTHAN's - C Programming Language notes
SULTHAN's - C Programming Language notes
SULTHAN BASHA
 
Dia internacional de la mujer vanessa
Dia internacional de la mujer vanessaDia internacional de la mujer vanessa
Dia internacional de la mujer vanessa
16vanessa
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
Vivek Singh Chandel
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
MeoRamos
 
Ad

Similar to Loops in C Programming Language (20)

etlplooping-170320213203.pptx
etlplooping-170320213203.pptxetlplooping-170320213203.pptx
etlplooping-170320213203.pptx
ffyuyufyfufufufu
 
Loops in C.pptx
Loops in C.pptxLoops in C.pptx
Loops in C.pptx
nagalakshmig4
 
loops and iteration.docx
loops and iteration.docxloops and iteration.docx
loops and iteration.docx
JavvajiVenkat
 
Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020
Osama Ghandour Geris
 
Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020
Osama Ghandour Geris
 
2nd year computer science chapter 12 notes
2nd year computer science chapter 12 notes2nd year computer science chapter 12 notes
2nd year computer science chapter 12 notes
muhammadFaheem656405
 
C Programming: Looping Statements in C Pgm
C Programming: Looping Statements in C PgmC Programming: Looping Statements in C Pgm
C Programming: Looping Statements in C Pgm
Navya Francis
 
Looping (Computer programming and utilization)
Looping (Computer programming and utilization)Looping (Computer programming and utilization)
Looping (Computer programming and utilization)
Digvijaysinh Gohil
 
Loops
LoopsLoops
Loops
SAMYAKKHADSE
 
Loops in c
Loops in cLoops in c
Loops in c
RekhaBudhwar
 
LOOP STATEMENTS AND TYPES OF LOOP IN C LANGUAGE BY RIZWAN
LOOP STATEMENTS AND TYPES OF LOOP IN C LANGUAGE BY RIZWANLOOP STATEMENTS AND TYPES OF LOOP IN C LANGUAGE BY RIZWAN
LOOP STATEMENTS AND TYPES OF LOOP IN C LANGUAGE BY RIZWAN
MD RIZWAN MOLLA
 
C lecture 3 control statements slideshare
C lecture 3 control statements slideshareC lecture 3 control statements slideshare
C lecture 3 control statements slideshare
Gagan Deep
 
cpu.pdf
cpu.pdfcpu.pdf
cpu.pdf
RAJCHATTERJEE24
 
Looping statements
Looping statementsLooping statements
Looping statements
Chukka Nikhil Chakravarthy
 
Loops in Cjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.pptx
Loops in Cjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.pptxLoops in Cjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.pptx
Loops in Cjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.pptx
tanaykapse999
 
itretion.docx
itretion.docxitretion.docx
itretion.docx
JavvajiVenkat
 
Chap 6(decision making-looping)
Chap 6(decision making-looping)Chap 6(decision making-looping)
Chap 6(decision making-looping)
Bangabandhu Sheikh Mujibur Rahman Science and Technology University
 
Loops Basics
Loops BasicsLoops Basics
Loops Basics
Mushiii
 
Chapter06.PPT
Chapter06.PPTChapter06.PPT
Chapter06.PPT
vamsiKrishnasai3
 
175035-cse LAB-04
175035-cse LAB-04 175035-cse LAB-04
175035-cse LAB-04
Mahbubay Rabbani Mim
 
Ad

Recently uploaded (20)

Software Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance OptimizationSoftware Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance Optimization
kiwoong (daniel) kim
 
Cloud Computing storage saas iaas paas.pptx
Cloud Computing storage saas iaas paas.pptxCloud Computing storage saas iaas paas.pptx
Cloud Computing storage saas iaas paas.pptx
viratkohli82222
 
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra OpticaPruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
OmarAlfredoDelCastil
 
First Review PPT gfinal gyft ftu liu yrfut go
First Review PPT gfinal gyft  ftu liu yrfut goFirst Review PPT gfinal gyft  ftu liu yrfut go
First Review PPT gfinal gyft ftu liu yrfut go
Sowndarya6
 
Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)
pelumiadigun2006
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghjfHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
yadavshivank2006
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
Influence line diagram in a robust model
Influence line diagram in a robust modelInfluence line diagram in a robust model
Influence line diagram in a robust model
ParthaSengupta26
 
Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...
Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...
Forecasting Road Accidents Using Deep Learning Approach: Policies to Improve ...
Journal of Soft Computing in Civil Engineering
 
introduction to Digital Signature basics
introduction to Digital Signature basicsintroduction to Digital Signature basics
introduction to Digital Signature basics
DhavalPatel171802
 
FISICA ESTATICA DESING LOADS CAPITULO 2.
FISICA ESTATICA DESING LOADS CAPITULO 2.FISICA ESTATICA DESING LOADS CAPITULO 2.
FISICA ESTATICA DESING LOADS CAPITULO 2.
maldonadocesarmanuel
 
Characterization of Polymeric Materials by Thermal Analysis, Spectroscopy an...
Characterization of Polymeric Materials by Thermal Analysis,  Spectroscopy an...Characterization of Polymeric Materials by Thermal Analysis,  Spectroscopy an...
Characterization of Polymeric Materials by Thermal Analysis, Spectroscopy an...
1SI20ME092ShivayogiB
 
Artificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowyArtificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowy
dominikamizerska1
 
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
sebastianku31
 
Introduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptxIntroduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptx
gunjalsachin
 
Webinar On Steel Melting IIF of steel for rdso
Webinar  On Steel  Melting IIF of steel for rdsoWebinar  On Steel  Melting IIF of steel for rdso
Webinar On Steel Melting IIF of steel for rdso
KapilParyani3
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdfRearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
ANFIS Models with Subtractive Clustering and Fuzzy C-Mean Clustering Techniqu...
ANFIS Models with Subtractive Clustering and Fuzzy C-Mean Clustering Techniqu...ANFIS Models with Subtractive Clustering and Fuzzy C-Mean Clustering Techniqu...
ANFIS Models with Subtractive Clustering and Fuzzy C-Mean Clustering Techniqu...
Journal of Soft Computing in Civil Engineering
 
Class-Symbols for vessels ships shipyards.pdf
Class-Symbols for vessels ships shipyards.pdfClass-Symbols for vessels ships shipyards.pdf
Class-Symbols for vessels ships shipyards.pdf
takisvlastos
 
Software Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance OptimizationSoftware Developer Portfolio: Backend Architecture & Performance Optimization
Software Developer Portfolio: Backend Architecture & Performance Optimization
kiwoong (daniel) kim
 
Cloud Computing storage saas iaas paas.pptx
Cloud Computing storage saas iaas paas.pptxCloud Computing storage saas iaas paas.pptx
Cloud Computing storage saas iaas paas.pptx
viratkohli82222
 
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra OpticaPruebas y Solucion de problemas empresariales en redes de Fibra Optica
Pruebas y Solucion de problemas empresariales en redes de Fibra Optica
OmarAlfredoDelCastil
 
First Review PPT gfinal gyft ftu liu yrfut go
First Review PPT gfinal gyft  ftu liu yrfut goFirst Review PPT gfinal gyft  ftu liu yrfut go
First Review PPT gfinal gyft ftu liu yrfut go
Sowndarya6
 
Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)Strength of materials (Thermal stress and strain relationships)
Strength of materials (Thermal stress and strain relationships)
pelumiadigun2006
 
Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401Universal Human Values and professional ethics Quantum AKTU BVE401
Universal Human Values and professional ethics Quantum AKTU BVE401
Unknown
 
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghjfHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
fHUINhKG5lM1WBBk608.pptxfhjjhhjffhiuhhghj
yadavshivank2006
 
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdfIrja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus - Beyond Pass and Fail - DevTalks.pdf
Irja Straus
 
Influence line diagram in a robust model
Influence line diagram in a robust modelInfluence line diagram in a robust model
Influence line diagram in a robust model
ParthaSengupta26
 
introduction to Digital Signature basics
introduction to Digital Signature basicsintroduction to Digital Signature basics
introduction to Digital Signature basics
DhavalPatel171802
 
FISICA ESTATICA DESING LOADS CAPITULO 2.
FISICA ESTATICA DESING LOADS CAPITULO 2.FISICA ESTATICA DESING LOADS CAPITULO 2.
FISICA ESTATICA DESING LOADS CAPITULO 2.
maldonadocesarmanuel
 
Characterization of Polymeric Materials by Thermal Analysis, Spectroscopy an...
Characterization of Polymeric Materials by Thermal Analysis,  Spectroscopy an...Characterization of Polymeric Materials by Thermal Analysis,  Spectroscopy an...
Characterization of Polymeric Materials by Thermal Analysis, Spectroscopy an...
1SI20ME092ShivayogiB
 
Artificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowyArtificial Power 2025 raport krajobrazowy
Artificial Power 2025 raport krajobrazowy
dominikamizerska1
 
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
May 2025: Top 10 Cited Articles in Software Engineering & Applications Intern...
sebastianku31
 
Introduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptxIntroduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptx
gunjalsachin
 
Webinar On Steel Melting IIF of steel for rdso
Webinar  On Steel  Melting IIF of steel for rdsoWebinar  On Steel  Melting IIF of steel for rdso
Webinar On Steel Melting IIF of steel for rdso
KapilParyani3
 
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdfRearchitecturing a 9-year-old legacy Laravel application.pdf
Rearchitecturing a 9-year-old legacy Laravel application.pdf
Takumi Amitani
 
Class-Symbols for vessels ships shipyards.pdf
Class-Symbols for vessels ships shipyards.pdfClass-Symbols for vessels ships shipyards.pdf
Class-Symbols for vessels ships shipyards.pdf
takisvlastos
 

Loops in C Programming Language

  • 2. Content  Objective  Introduction Types of looping while do-while for  Assessment metric Conclusion References
  • 3. Course Objective  Understand the basic terminology used in computer programming  It stresses the strengths of C, which provide students with the means of writing efficient, maintainable, and portable code.  write, compile and debug programs in C language.  Increase the ability to learn new programming languages OBJECTIVES
  • 4. Topic Objective  Understand the basics of looping.  To use the while, do-while and for repetition statement to execute statements in a program repeatedly.
  • 5. INTRODUCTION  Statements in a program are executed one after the other ex: statement 1; statement 2; : statement n;  Sometimes, the user want to execute a set of statements repeatedly.
  • 6.  Loop statements are used to repeat the execution of statement or blocks. Iteration of a loop: the number of times the body of loop is executed.  Two types of loop structure are: Pretest : Entry - controlled loop Posttest : Exit – controlled loop
  • 7. Pretest Vs. Posttest Pretest : Condition is tested before each iteration to check if loops should occur. Posttest : Condition is tested after each iteration to check if loop should continue (at least a single iteration occurs). Conditio n Evaluate d Statements false true Conditio n Evaluate d Statements true false
  • 8. TYPES OF LOOP  while loop  do-while loop  for loop
  • 9. while Loop  It has a loop condition only that is tested before each iteration to decide whether to continue or terminate the loop.  The body of a while loop will execute zero or more times Syntax: while (<condition>){ <statement/block>; }
  • 11. do…while Loop  Do while has a loop condition only that is tested after each iteration to decide whether to continue with next iteration or terminate the loop. Syntax: do{ <statement/block>; }while(condition);
  • 12. Example: int i=0; do{ Printf (“Hellon”); i++; } while (i<3); Output: Hello Hello Hello Conditio n Evaluate d Statements true false Flow diagram
  • 13. for Loop for loop has three parts:  Initializer is executed at start of loop.  Loop condition is tested before iteration to decide whether to continue or terminate the loop.  Increment is executed at the end of each loop iteration.
  • 14. Syntax: for( [initialize]; [condition]; [incrementor] ) { <statement/block>; } Conditio n Evaluate d initialization Statements increament true false Flow diagram
  • 16. ASSESSMENT METRIC  What is looping? List the types of looping.  Explain the while loop with an example.  Give the difference between while and do-while loops  Explain the syntax of for loop with an example  List out the difference between while and for loop. And also explain the do-while loop.
  • 17. CONCLUSION  Importance of loops in any programming language is immense, they allow us to reduce the number of lines in a code, making our code more readable and efficient.
  • 18. REFERENCES [1]. E. Balaguruswamy, “Programming in ANSI C”, Third edition, Tata McGraw Hill Publications, 2002. [2]. P. B. Kotur, “Computer Concepts and C programming”, Kindle Edition, Sapna Book House, Bangalore, 2009.