SlideShare a Scribd company logo
1 of 13
C language Loop Control
(for , while , do while)
Copyright © 2015 · Sourav Ganguly · All Rights Reserved.
Sourav Ganguly
Please visit my Youtube channel
Step 1: go to www.google.com
Step 2: Search for “sourav ganguly c programming”.
Step 3: Click on my image bottom of the video. You will reach my
channel.
Youtube (direct link):
https://www.youtube.com/channel/UCDsQskBhM107VIYLjg8kczg
Website:
http://www.startselfstudy.blogspot.in
Copyright © 2015 · Sourav Ganguly · All Rights Reserved.
for loop of C language…..
Different types of for loop in C language…..
for loop example with real program…..
[Live Demo on YouTube channel]
while loop of C language…..
Different types of while loop in C language…..
while loop example with real program…..
[Live Demo on YouTube channel]
do while loop of C language…..
Different types of do while loop in C language…..
do while loop example with real program…..
[Live Demo on YouTube channel]
Index
Copyright © 2015 · Sourav Ganguly · All Rights Reserved.
for loop of C language…..
for ( initialization ; condition(TRUE / FALSE) ; increment / decrement )
{
Task / Job;
}
int x;
for ( x=0 ; x < 3 ; x=x+1 )
{
printf(“%d”,x);
printf(“n”);
}
printf(“Loop end”);
Output:
0
1
2
Loop end
Copyright © 2015 · Sourav Ganguly · All Rights Reserved.
6
1 2
3
4
5
for ( initialization ; condition(TRUE / FALSE) ; increment / decrement )
{
for ( init ; con(TRUE / FALSE) ; inc / dec )
{
Task / Job;
}
}
Copyright © 2015 · Sourav Ganguly · All Rights Reserved.
12
1 2
3
4
11
5
6
7
8
9
10
nested for loop of C language…..
int loop1,loop2;
for ( loop1=0 ; loop1 < 3 ; loop1=loop1+1 )
{
for ( loop2=0 ; loop2 < 3 ; loop2=loop2+1 )
{
printf(“%d”,loop2);
}
printf(“n”);
printf(“Loop2 end”);
printf(“n”);
}
printf(“Loop1 end”);
Output:
012
Loop2 end
012
Loop2 end
012
Loop2 end
Loop1 end
Copyright © 2015 · Sourav Ganguly · All Rights Reserved.
nested for loop of C language….. example
initialization ;
while (condition(TRUE / FALSE) )
{
Task / Job;
increment / decrement ;
}
int x=0;
while ( x < 3 )
{
printf(“n%d”,x);
x=x+1;
}
printf(“Loop end”);
Output:
0
1
2
Loop end
Copyright © 2015 · Sourav Ganguly · All Rights Reserved.
5
1 2
3 4
while loop of C language…..
initialization ;
while (condition(TRUE / FALSE) )
{
init ;
while (con(TRUE / FALSE))
{
Task / Job;
inc / dec ;
}
increment / decrement ;
}
Copyright © 2015 · Sourav Ganguly · All Rights Reserved.
1 2
3
4
9
5
6
7
8
10
nested while loop of C language…..
int loop1,loop2;
loop1=0 ;
while (loop1 < 3)
{
loop2=0 ;
while (loop2 < 3)
{
printf(“%d”,loop2);
loop2=loop2+1;
}
printf(“n”);
printf(“Loop2 end”);
loop1=loop1+1;
}
printf(“Loop1 end”);
Output:
012
Loop2 end
012
Loop2 end
012
Loop2 end
Loop1 end
Copyright © 2015 · Sourav Ganguly · All Rights Reserved.
nested while loop of C language….. example
initialization ;
do
{
Task / Job;
increment / decrement ;
}
while (condition(TRUE / FALSE) ) ;
int x=0;
do
{
printf(“n%d”,x);
x=x+1;
} while( x < 3 );
printf(“Loop end”);
Output:
0
1
2
Loop end
Copyright © 2015 · Sourav Ganguly · All Rights Reserved.
6
1
2
4
5
do while loop of C language…..
3
initialization ;
do
{
init ;
do
{
Task / Job;
inc / dec ;
}
while (con(TRUE / FALSE))
increment / decrement ;
}
while (condition(TRUE / FALSE) )
Copyright © 2015 · Sourav Ganguly · All Rights Reserved.
1
2
3
4
11
5
6
7
8
12
nested do while loop of C language…..
10
9
int loop1,loop2;
loop1=0 ;
do
{
loop2=0 ;
do
{
printf(“%d”,loop2);
loop2=loop2+1;
} while (loop2 < 3) ;
printf(“n”);
printf(“Loop2 end”);
loop1=loop1+1;
} while (loop1 < 3);
printf(“Loop1 end”);
Output:
012
Loop2 end
012
Loop2 end
012
Loop2 end
Loop1 end
Copyright © 2015 · Sourav Ganguly · All Rights Reserved.
nested do while loop of C language….. example
Sourav Ganguly
Please visit my Youtube channel
Step 1: go to www.google.com
Step 2: Search for “sourav ganguly c programming”.
Step 3: Click on my image bottom of the video. You will reach my
channel.
Youtube (direct link):
https://www.youtube.com/channel/UCDsQskBhM107VIYLjg8kczg
Website:
http://www.startselfstudy.blogspot.in
Copyright © 2015 · Sourav Ganguly · All Rights Reserved.

More Related Content

What's hot

What's hot (20)

Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
 
Break and continue
Break and continueBreak and continue
Break and continue
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
 
Do...while loop structure
Do...while loop structureDo...while loop structure
Do...while loop structure
 
Types of loops in c language
Types of loops in c languageTypes of loops in c language
Types of loops in c language
 
Looping statement
Looping statementLooping statement
Looping statement
 
Looping statements
Looping statementsLooping statements
Looping statements
 
Looping Statement And Flow Chart
 Looping Statement And Flow Chart Looping Statement And Flow Chart
Looping Statement And Flow Chart
 
Loops
LoopsLoops
Loops
 
The Loops
The LoopsThe Loops
The Loops
 
Iteration
IterationIteration
Iteration
 
Jumping statements
Jumping statementsJumping statements
Jumping statements
 
types of loops and what is loop
types of loops and what is looptypes of loops and what is loop
types of loops and what is loop
 
Loops c++
Loops c++Loops c++
Loops c++
 
Loops in c
Loops in cLoops in c
Loops in c
 
170120107074 looping statements and nesting of loop statements
170120107074 looping statements and nesting of loop statements170120107074 looping statements and nesting of loop statements
170120107074 looping statements and nesting of loop statements
 
Nested loop in C language
Nested loop in C languageNested loop in C language
Nested loop in C language
 
Looping
LoopingLooping
Looping
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
 

Viewers also liked

Basic for Loop in C
Basic for Loop in CBasic for Loop in C
Basic for Loop in CRohit Soni
 
Memory allocation in c
Memory allocation in cMemory allocation in c
Memory allocation in cPrabhu Govind
 
detailed information about Pointers in c language
detailed information about Pointers in c languagedetailed information about Pointers in c language
detailed information about Pointers in c languagegourav kottawar
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controlsvinay arora
 
C Pointers
C PointersC Pointers
C Pointersomukhtar
 

Viewers also liked (6)

Basic for Loop in C
Basic for Loop in CBasic for Loop in C
Basic for Loop in C
 
Structure in C
Structure in CStructure in C
Structure in C
 
Memory allocation in c
Memory allocation in cMemory allocation in c
Memory allocation in c
 
detailed information about Pointers in c language
detailed information about Pointers in c languagedetailed information about Pointers in c language
detailed information about Pointers in c language
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controls
 
C Pointers
C PointersC Pointers
C Pointers
 

Similar to C program language tutorial for loop while loop do while loop

How to write c programme
How to write c programmeHow to write c programme
How to write c programmeSourav Ganguly
 
Arduino programming of ML-style in ATS
Arduino programming of ML-style in ATSArduino programming of ML-style in ATS
Arduino programming of ML-style in ATSKiwamu Okabe
 
decision making in c.pptx
decision making in c.pptxdecision making in c.pptx
decision making in c.pptxDrGAMBIKA
 
Brand New JavaScript - ECMAScript 2015
Brand New JavaScript - ECMAScript 2015Brand New JavaScript - ECMAScript 2015
Brand New JavaScript - ECMAScript 2015Gil Fink
 
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis LazuliGetting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis LazuliRebecca Eloise Hogg
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and loopingChaAstillas
 
My programming final proj. (1)
My programming final proj. (1)My programming final proj. (1)
My programming final proj. (1)aeden_brines
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!olracoatalub
 
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang) [Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang) Johnny Sung
 
C Programming Language Part 6
C Programming Language Part 6C Programming Language Part 6
C Programming Language Part 6Rumman Ansari
 
Enabling Java in Latency Sensitive Environments
Enabling Java in Latency Sensitive EnvironmentsEnabling Java in Latency Sensitive Environments
Enabling Java in Latency Sensitive EnvironmentsC4Media
 
Switch case and looping kim
Switch case and looping kimSwitch case and looping kim
Switch case and looping kimkimberly_Bm10203
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping newaprilyyy
 

Similar to C program language tutorial for loop while loop do while loop (20)

How to write c programme
How to write c programmeHow to write c programme
How to write c programme
 
Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020
 
Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020Week2 ch4 part1edited 2020
Week2 ch4 part1edited 2020
 
Arduino programming of ML-style in ATS
Arduino programming of ML-style in ATSArduino programming of ML-style in ATS
Arduino programming of ML-style in ATS
 
decision making in c.pptx
decision making in c.pptxdecision making in c.pptx
decision making in c.pptx
 
C++ programming
C++ programmingC++ programming
C++ programming
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Brand New JavaScript - ECMAScript 2015
Brand New JavaScript - ECMAScript 2015Brand New JavaScript - ECMAScript 2015
Brand New JavaScript - ECMAScript 2015
 
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis LazuliGetting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
Getting Started with Test Automation: Introduction to Cucumber with Lapis Lazuli
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Elements of programming
Elements of programmingElements of programming
Elements of programming
 
neiljaysonching
neiljaysonchingneiljaysonching
neiljaysonching
 
My programming final proj. (1)
My programming final proj. (1)My programming final proj. (1)
My programming final proj. (1)
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!
 
Decision Making and Looping
Decision Making and LoopingDecision Making and Looping
Decision Making and Looping
 
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang) [Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
 
C Programming Language Part 6
C Programming Language Part 6C Programming Language Part 6
C Programming Language Part 6
 
Enabling Java in Latency Sensitive Environments
Enabling Java in Latency Sensitive EnvironmentsEnabling Java in Latency Sensitive Environments
Enabling Java in Latency Sensitive Environments
 
Switch case and looping kim
Switch case and looping kimSwitch case and looping kim
Switch case and looping kim
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping new
 

Recently uploaded

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 

Recently uploaded (20)

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 

C program language tutorial for loop while loop do while loop

  • 1. C language Loop Control (for , while , do while) Copyright © 2015 · Sourav Ganguly · All Rights Reserved.
  • 2. Sourav Ganguly Please visit my Youtube channel Step 1: go to www.google.com Step 2: Search for “sourav ganguly c programming”. Step 3: Click on my image bottom of the video. You will reach my channel. Youtube (direct link): https://www.youtube.com/channel/UCDsQskBhM107VIYLjg8kczg Website: http://www.startselfstudy.blogspot.in Copyright © 2015 · Sourav Ganguly · All Rights Reserved.
  • 3. for loop of C language….. Different types of for loop in C language….. for loop example with real program….. [Live Demo on YouTube channel] while loop of C language….. Different types of while loop in C language….. while loop example with real program….. [Live Demo on YouTube channel] do while loop of C language….. Different types of do while loop in C language….. do while loop example with real program….. [Live Demo on YouTube channel] Index Copyright © 2015 · Sourav Ganguly · All Rights Reserved.
  • 4. for loop of C language….. for ( initialization ; condition(TRUE / FALSE) ; increment / decrement ) { Task / Job; } int x; for ( x=0 ; x < 3 ; x=x+1 ) { printf(“%d”,x); printf(“n”); } printf(“Loop end”); Output: 0 1 2 Loop end Copyright © 2015 · Sourav Ganguly · All Rights Reserved. 6 1 2 3 4 5
  • 5. for ( initialization ; condition(TRUE / FALSE) ; increment / decrement ) { for ( init ; con(TRUE / FALSE) ; inc / dec ) { Task / Job; } } Copyright © 2015 · Sourav Ganguly · All Rights Reserved. 12 1 2 3 4 11 5 6 7 8 9 10 nested for loop of C language…..
  • 6. int loop1,loop2; for ( loop1=0 ; loop1 < 3 ; loop1=loop1+1 ) { for ( loop2=0 ; loop2 < 3 ; loop2=loop2+1 ) { printf(“%d”,loop2); } printf(“n”); printf(“Loop2 end”); printf(“n”); } printf(“Loop1 end”); Output: 012 Loop2 end 012 Loop2 end 012 Loop2 end Loop1 end Copyright © 2015 · Sourav Ganguly · All Rights Reserved. nested for loop of C language….. example
  • 7. initialization ; while (condition(TRUE / FALSE) ) { Task / Job; increment / decrement ; } int x=0; while ( x < 3 ) { printf(“n%d”,x); x=x+1; } printf(“Loop end”); Output: 0 1 2 Loop end Copyright © 2015 · Sourav Ganguly · All Rights Reserved. 5 1 2 3 4 while loop of C language…..
  • 8. initialization ; while (condition(TRUE / FALSE) ) { init ; while (con(TRUE / FALSE)) { Task / Job; inc / dec ; } increment / decrement ; } Copyright © 2015 · Sourav Ganguly · All Rights Reserved. 1 2 3 4 9 5 6 7 8 10 nested while loop of C language…..
  • 9. int loop1,loop2; loop1=0 ; while (loop1 < 3) { loop2=0 ; while (loop2 < 3) { printf(“%d”,loop2); loop2=loop2+1; } printf(“n”); printf(“Loop2 end”); loop1=loop1+1; } printf(“Loop1 end”); Output: 012 Loop2 end 012 Loop2 end 012 Loop2 end Loop1 end Copyright © 2015 · Sourav Ganguly · All Rights Reserved. nested while loop of C language….. example
  • 10. initialization ; do { Task / Job; increment / decrement ; } while (condition(TRUE / FALSE) ) ; int x=0; do { printf(“n%d”,x); x=x+1; } while( x < 3 ); printf(“Loop end”); Output: 0 1 2 Loop end Copyright © 2015 · Sourav Ganguly · All Rights Reserved. 6 1 2 4 5 do while loop of C language….. 3
  • 11. initialization ; do { init ; do { Task / Job; inc / dec ; } while (con(TRUE / FALSE)) increment / decrement ; } while (condition(TRUE / FALSE) ) Copyright © 2015 · Sourav Ganguly · All Rights Reserved. 1 2 3 4 11 5 6 7 8 12 nested do while loop of C language….. 10 9
  • 12. int loop1,loop2; loop1=0 ; do { loop2=0 ; do { printf(“%d”,loop2); loop2=loop2+1; } while (loop2 < 3) ; printf(“n”); printf(“Loop2 end”); loop1=loop1+1; } while (loop1 < 3); printf(“Loop1 end”); Output: 012 Loop2 end 012 Loop2 end 012 Loop2 end Loop1 end Copyright © 2015 · Sourav Ganguly · All Rights Reserved. nested do while loop of C language….. example
  • 13. Sourav Ganguly Please visit my Youtube channel Step 1: go to www.google.com Step 2: Search for “sourav ganguly c programming”. Step 3: Click on my image bottom of the video. You will reach my channel. Youtube (direct link): https://www.youtube.com/channel/UCDsQskBhM107VIYLjg8kczg Website: http://www.startselfstudy.blogspot.in Copyright © 2015 · Sourav Ganguly · All Rights Reserved.