SlideShare a Scribd company logo
7
Most read
9
Most read
14
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

PPTX
Types of loops in c language
PPTX
Loops in c language
PPTX
Looping statements in C
PPTX
The Loops
PPTX
Loops in c programming
PPT
PPTX
Loops in C
Types of loops in c language
Loops in c language
Looping statements in C
The Loops
Loops in c programming
Loops in C

What's hot (20)

PPTX
Control statements in c
PPTX
Data types in C
PPT
C by balaguruswami - e.balagurusamy
PPTX
Dynamic memory allocation in c
PDF
Control statements
PPTX
Loops c++
PPT
Operators in C Programming
PPT
RECURSION IN C
PPTX
C Programming: Control Structure
PPT
Basic concept of OOP's
PPT
History of c
PPT
Input and output in C++
PPT
Control structure C++
PPT
Structure of a C program
PPTX
Presentation on Function in C Programming
PPT
Array in c
PPTX
Control Statements in Java
PPTX
classes and objects in C++
PDF
Introduction to c++ ppt
PPTX
Pointer in c
Control statements in c
Data types in C
C by balaguruswami - e.balagurusamy
Dynamic memory allocation in c
Control statements
Loops c++
Operators in C Programming
RECURSION IN C
C Programming: Control Structure
Basic concept of OOP's
History of c
Input and output in C++
Control structure C++
Structure of a C program
Presentation on Function in C Programming
Array in c
Control Statements in Java
classes and objects in C++
Introduction to c++ ppt
Pointer in c
Ad

Viewers also liked (20)

PPTX
Videos indexing and retrieval using XML/XQuery
PPTX
Business Model Designing (in Chinese)
PDF
C Prog. - Decision & Loop Controls
PPTX
Loops in C Programming
PPTX
Social media update
PPT
Basics of C programming
PPTX
C decision making and looping.
PPTX
Looping and Switchcase BDCR
PDF
How to Become a Thought Leader in Your Niche
PPTX
Conditional Statement in C Language
PPT
Fundamentals of programming finals.ajang
PPTX
Unit 4a
PPT
Looping in C
PDF
Parsing XML in J2ME
PDF
Lecture3 ode (1) lamia
PPTX
Looping statement
PDF
SULTHAN's - C Programming Language notes
DOCX
Dia internacional de la mujer vanessa
PPSX
Complete C programming Language Course
Videos indexing and retrieval using XML/XQuery
Business Model Designing (in Chinese)
C Prog. - Decision & Loop Controls
Loops in C Programming
Social media update
Basics of C programming
C decision making and looping.
Looping and Switchcase BDCR
How to Become a Thought Leader in Your Niche
Conditional Statement in C Language
Fundamentals of programming finals.ajang
Unit 4a
Looping in C
Parsing XML in J2ME
Lecture3 ode (1) lamia
Looping statement
SULTHAN's - C Programming Language notes
Dia internacional de la mujer vanessa
Complete C programming Language Course
Ad

Similar to Loops in C Programming Language (20)

PPTX
etlplooping-170320213203.pptx
PPTX
Loops in C.pptx
DOCX
loops and iteration.docx
PPT
Week2 ch4 part1edited 2020
PPT
Week2 ch4 part1edited 2020
PPTX
2nd year computer science chapter 12 notes
PPTX
C Programming: Looping Statements in C Pgm
PPTX
Looping (Computer programming and utilization)
PPTX
PPTX
Loops in c
PDF
LOOP STATEMENTS AND TYPES OF LOOP IN C LANGUAGE BY RIZWAN
PPTX
While , For , Do-While Loop
PPSX
C lecture 3 control statements slideshare
PDF
DOCX
Looping statements
PPTX
Loops in Cjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.pptx
DOCX
itretion.docx
PPTX
Loops Basics
PPT
Chapter06.PPT
etlplooping-170320213203.pptx
Loops in C.pptx
loops and iteration.docx
Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020
2nd year computer science chapter 12 notes
C Programming: Looping Statements in C Pgm
Looping (Computer programming and utilization)
Loops in c
LOOP STATEMENTS AND TYPES OF LOOP IN C LANGUAGE BY RIZWAN
While , For , Do-While Loop
C lecture 3 control statements slideshare
Looping statements
Loops in Cjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.pptx
itretion.docx
Loops Basics
Chapter06.PPT

Recently uploaded (20)

PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Well-logging-methods_new................
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
Construction Project Organization Group 2.pptx
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PDF
Digital Logic Computer Design lecture notes
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
web development for engineering and engineering
PPTX
Lecture Notes Electrical Wiring System Components
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPT
Project quality management in manufacturing
PPTX
Welding lecture in detail for understanding
DOCX
573137875-Attendance-Management-System-original
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
composite construction of structures.pdf
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
CYBER-CRIMES AND SECURITY A guide to understanding
Well-logging-methods_new................
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Construction Project Organization Group 2.pptx
Lesson 3_Tessellation.pptx finite Mathematics
Digital Logic Computer Design lecture notes
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
web development for engineering and engineering
Lecture Notes Electrical Wiring System Components
Embodied AI: Ushering in the Next Era of Intelligent Systems
Strings in CPP - Strings in C++ are sequences of characters used to store and...
OOP with Java - Java Introduction (Basics)
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Project quality management in manufacturing
Welding lecture in detail for understanding
573137875-Attendance-Management-System-original
CH1 Production IntroductoryConcepts.pptx
composite construction of structures.pdf

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.