SlideShare a Scribd company logo
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

Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
programming9
 
C tokens
C tokensC tokens
C tokens
Manu1325
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
sneha2494
 
C language ppt
C language pptC language ppt
C language ppt
Ğäùråv Júñêjå
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in CSahithi Naraparaju
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
Sokngim Sa
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
Harshita Yadav
 
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
Harendra Singh
 
History of c
History of cHistory of c
History of c
Shipat Bhuiya
 
Forloop
ForloopForloop
Forloop
Dipen Vasoya
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
tanmaymodi4
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
Abhishek Choksi
 
Strings in C
Strings in CStrings in C
Strings in C
Kamal Acharya
 
Loops in c++ programming language
Loops in c++ programming language Loops in c++ programming language
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming9
 
C if else
C if elseC if else
C if else
Ritwik Das
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
savitamhaske
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
Wingston
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 

What's hot (20)

Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
C tokens
C tokensC tokens
C tokens
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
 
C language ppt
C language pptC language ppt
C language ppt
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
 
History of c
History of cHistory of c
History of c
 
Forloop
ForloopForloop
Forloop
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
 
Strings in C
Strings in CStrings in C
Strings in C
 
Loops in c++ programming language
Loops in c++ programming language Loops in c++ programming language
Loops in c++ programming language
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
C if else
C if elseC if else
C if else
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 

Viewers also liked

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 Controlsvinay arora
 
Loops in C Programming
Loops in C ProgrammingLoops in C Programming
Loops in C Programming
Himanshu Negi
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
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 BDCRberiver
 
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.ajangJaricka 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) lamiamalkinh
 
Looping statement
Looping statementLooping statement
Looping statementilakkiya
 
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 chan
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch casesMeoRamos
 

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
 
Business Model Designing (in Chinese)
Business Model Designing (in Chinese)Business Model Designing (in Chinese)
Business Model Designing (in Chinese)
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controls
 
Loops in C Programming
Loops in C ProgrammingLoops in C Programming
Loops in C Programming
 
Social media update
Social media updateSocial media update
Social media update
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
Looping and Switchcase BDCR
Looping and Switchcase BDCRLooping and Switchcase BDCR
Looping and Switchcase BDCR
 
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
 
Fundamentals of programming finals.ajang
Fundamentals of programming finals.ajangFundamentals of programming finals.ajang
Fundamentals of programming finals.ajang
 
Unit 4a
Unit 4aUnit 4a
Unit 4a
 
Looping in C
Looping in CLooping in C
Looping in C
 
Parsing XML in J2ME
Parsing XML in J2MEParsing XML in J2ME
Parsing XML in J2ME
 
Lecture3 ode (1) lamia
Lecture3 ode (1) lamiaLecture3 ode (1) lamia
Lecture3 ode (1) lamia
 
Looping
LoopingLooping
Looping
 
Looping statement
Looping statementLooping statement
Looping statement
 
SULTHAN's - C Programming Language notes
SULTHAN's - C Programming Language notesSULTHAN's - C Programming Language notes
SULTHAN's - C Programming Language notes
 
Dia internacional de la mujer vanessa
Dia internacional de la mujer vanessaDia internacional de la mujer vanessa
Dia internacional de la mujer vanessa
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
 

Similar to Loops in C Programming Language

Loops in C.pptx
Loops in C.pptxLoops in C.pptx
Loops in C.pptx
nagalakshmig4
 
While loop,Do While loop ,for loop
While loop,Do While loop ,for loop While loop,Do While loop ,for loop
While loop,Do While loop ,for loop
MuhammadWaseem305
 
Loops in c++
Loops in c++Loops in c++
Loops in c++
Rebin Daho
 
itretion.docx
itretion.docxitretion.docx
itretion.docx
JavvajiVenkat
 
Chapter 3 - Flow of Control Part II.pdf
Chapter 3  - Flow of Control Part II.pdfChapter 3  - Flow of Control Part II.pdf
Chapter 3 - Flow of Control Part II.pdf
KirubelWondwoson1
 
Loops and iteration.docx
Loops and iteration.docxLoops and iteration.docx
Loops and iteration.docx
NkurikiyimanaGodefre
 
loops and iteration.docx
loops and iteration.docxloops and iteration.docx
loops and iteration.docx
JavvajiVenkat
 
Control Statement IN C.pptx
Control Statement IN C.pptxControl Statement IN C.pptx
Control Statement IN C.pptx
sujatha629799
 
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
Dheemaan Daash
 
Cpp loop types
Cpp loop typesCpp loop types
Cpp loop types
Rj Baculo
 
presentation on powerpoint template.pptx
presentation on powerpoint template.pptxpresentation on powerpoint template.pptx
presentation on powerpoint template.pptx
farantouqeer8
 
Loop-1.pptx
Loop-1.pptxLoop-1.pptx
dizital pods session 5-loops.pptx
dizital pods session 5-loops.pptxdizital pods session 5-loops.pptx
dizital pods session 5-loops.pptx
VijayKumarLokanadam
 
PPT_203105211_3.pptx
PPT_203105211_3.pptxPPT_203105211_3.pptx
PPT_203105211_3.pptx
SaurabhNage1
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
Tanmay Modi
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
tanmaymodi4
 
C language 2
C language 2C language 2
C language 2
Arafat Bin Reza
 
Visula C# Programming Lecture 4
Visula C# Programming Lecture 4Visula C# Programming Lecture 4
Visula C# Programming Lecture 4
Abou Bakr Ashraf
 

Similar to Loops in C Programming Language (20)

Loops in C.pptx
Loops in C.pptxLoops in C.pptx
Loops in C.pptx
 
While loop,Do While loop ,for loop
While loop,Do While loop ,for loop While loop,Do While loop ,for loop
While loop,Do While loop ,for loop
 
Loops in c++
Loops in c++Loops in c++
Loops in c++
 
itretion.docx
itretion.docxitretion.docx
itretion.docx
 
Chapter 3 - Flow of Control Part II.pdf
Chapter 3  - Flow of Control Part II.pdfChapter 3  - Flow of Control Part II.pdf
Chapter 3 - Flow of Control Part II.pdf
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Loops and iteration.docx
Loops and iteration.docxLoops and iteration.docx
Loops and iteration.docx
 
loops and iteration.docx
loops and iteration.docxloops and iteration.docx
loops and iteration.docx
 
Control Statement IN C.pptx
Control Statement IN C.pptxControl Statement IN C.pptx
Control Statement IN C.pptx
 
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
 
Cpp loop types
Cpp loop typesCpp loop types
Cpp loop types
 
Loops
LoopsLoops
Loops
 
presentation on powerpoint template.pptx
presentation on powerpoint template.pptxpresentation on powerpoint template.pptx
presentation on powerpoint template.pptx
 
Loop-1.pptx
Loop-1.pptxLoop-1.pptx
Loop-1.pptx
 
dizital pods session 5-loops.pptx
dizital pods session 5-loops.pptxdizital pods session 5-loops.pptx
dizital pods session 5-loops.pptx
 
PPT_203105211_3.pptx
PPT_203105211_3.pptxPPT_203105211_3.pptx
PPT_203105211_3.pptx
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
Loops in c language
Loops in c languageLoops in c language
Loops in c language
 
C language 2
C language 2C language 2
C language 2
 
Visula C# Programming Lecture 4
Visula C# Programming Lecture 4Visula C# Programming Lecture 4
Visula C# Programming Lecture 4
 

Recently uploaded

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
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
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
 
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
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
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
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
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
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
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
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 

Recently uploaded (20)

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
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
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
 
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
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
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
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
 
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
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 

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.