SlideShare a Scribd company logo
1 of 10
LOOP CONTROL
SHIVRAJ KUMAR
BSc CS in Kalinga Institute of Industrial
Technology (KiiT)
Patia, Bhubaneswar, Odisha
LOOP
A loop is define as a block of statement ,which
are repeatedly excuted for a certain number of
times .
LOOP
Entry control Exit control
do- while loop
For loop while loop
Syntex
For while do-while
For(intiliozation;condition;updation)
{
Statement;
}
While(condition)
{
Statement;
Updation;
}
do
{
Statement;
}
While(condition)
The for loop
The for loop allows to execute a set of
instruction until a certain condition satisfied.
EXAMPLE
For(int i=0;i<7;i++)
{
printf(“welcom for loop”);
}
Nested for loop
We can also use loop within loop. In nested for loop one
or more for statements are included in the body of the .
Example
For(int i=1;i<=3;i++)
{
For(int j=1;j<=2;j++)
{
printf(“n i*j:%d”,i*j);
}
}
Output
i*j=1
i*j=2
i*j=2
i*j=4
i*j=3
i*j=6
THE while loop
The while loop is frequently used in progrm for the
repeated execuation of satement in a loop.Until a certain
condition is satisfied the loop statements are executed.
Example
Int x=1;
While(x<5)
{
Printf(“you are begnners “);
X++;
}
Output
you are begnners
you are begnners
you are begnners
you are begnners
The do-while loop
A do...while loop is similar to a while loop, except the fact that it is
guaranteed to execute at least one time.
Example
#include <stdio.h>
int main ()
{
int a = 10;
do
{ printf("value of a: %dn", a);
a = a + 1;
}while( a < 20 );
return 0;
}
Output
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19
Comparision of the while and do-while
BY SRKP
.

More Related Content

Similar to Loop control

Computer programming
Computer programmingComputer programming
Computer programming
Xhyna Delfin
 

Similar to Loop control (20)

Loops In C++
Loops In C++Loops In C++
Loops In C++
 
Control statements
Control statementsControl statements
Control statements
 
Control statements
Control statementsControl statements
Control statements
 
Loops
LoopsLoops
Loops
 
Module 2- Control Structures
Module 2- Control StructuresModule 2- Control Structures
Module 2- Control Structures
 
Loop structures
Loop structuresLoop structures
Loop structures
 
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
 
CONTROL STMTS.pptx
CONTROL STMTS.pptxCONTROL STMTS.pptx
CONTROL STMTS.pptx
 
Loops in c++
Loops in c++Loops in c++
Loops in c++
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
 
Computer programming
Computer programmingComputer programming
Computer programming
 
5.pptx fundamental programing one branch
5.pptx fundamental programing one branch5.pptx fundamental programing one branch
5.pptx fundamental programing one branch
 
Cs1123 6 loops
Cs1123 6 loopsCs1123 6 loops
Cs1123 6 loops
 
Lecture - 5 Control Statement
Lecture - 5 Control StatementLecture - 5 Control Statement
Lecture - 5 Control Statement
 
22H51A6755.pptx
22H51A6755.pptx22H51A6755.pptx
22H51A6755.pptx
 
Decision making and loop in C#
Decision making and loop in C#Decision making and loop in C#
Decision making and loop in C#
 
Conditional Statements
Conditional StatementsConditional Statements
Conditional Statements
 
C-Programming Control statements.pptx
C-Programming Control statements.pptxC-Programming Control statements.pptx
C-Programming Control statements.pptx
 
C-Programming Control statements.pptx
C-Programming Control statements.pptxC-Programming Control statements.pptx
C-Programming Control statements.pptx
 
Programming loop
Programming loopProgramming loop
Programming loop
 

Recently uploaded

SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 

Recently uploaded (20)

How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 

Loop control

  • 1. LOOP CONTROL SHIVRAJ KUMAR BSc CS in Kalinga Institute of Industrial Technology (KiiT) Patia, Bhubaneswar, Odisha
  • 2. LOOP A loop is define as a block of statement ,which are repeatedly excuted for a certain number of times .
  • 3. LOOP Entry control Exit control do- while loop For loop while loop
  • 5. The for loop The for loop allows to execute a set of instruction until a certain condition satisfied. EXAMPLE For(int i=0;i<7;i++) { printf(“welcom for loop”); }
  • 6. Nested for loop We can also use loop within loop. In nested for loop one or more for statements are included in the body of the . Example For(int i=1;i<=3;i++) { For(int j=1;j<=2;j++) { printf(“n i*j:%d”,i*j); } } Output i*j=1 i*j=2 i*j=2 i*j=4 i*j=3 i*j=6
  • 7. THE while loop The while loop is frequently used in progrm for the repeated execuation of satement in a loop.Until a certain condition is satisfied the loop statements are executed. Example Int x=1; While(x<5) { Printf(“you are begnners “); X++; } Output you are begnners you are begnners you are begnners you are begnners
  • 8. The do-while loop A do...while loop is similar to a while loop, except the fact that it is guaranteed to execute at least one time. Example #include <stdio.h> int main () { int a = 10; do { printf("value of a: %dn", a); a = a + 1; }while( a < 20 ); return 0; } Output value of a: 10 value of a: 11 value of a: 12 value of a: 13 value of a: 14 value of a: 15 value of a: 16 value of a: 17 value of a: 18 value of a: 19
  • 9. Comparision of the while and do-while