SlideShare a Scribd company logo
Introduction to programming in C++ : Loop Structure.pptx
In Turbo C++, a for
loop is a control flow
statement that allows
code to be executed
repeatedly.
for (initialization;
condition;
increment/decrement) {
// code to be
executed
}
Initialization: This is where you initialize your
loop counter. This statement is executed only
once.
Condition: This is a boolean expression that the
system checks before each loop iteration. If it’s
true, the loop continues; if it’s false, the loop
ends.
Increment/Decrement: This statement is
executed at the end of each loop iteration.
#include<iostream.h>
#include<conio.h>
void main() {
clrscr();
for(int i = 1; i <= 10; i++) {
cout << i << "n";
}
getch();
return 0;
}
A while loop in programming is a control flow
statement that allows a certain piece of code to
be executed repeatedly based on a given
Boolean condition. The while loop can be
thought of as a repeating if statement. The
code inside the loop is executed, and then the
Boolean condition is evaluated. If the condition
is true, the code inside the loop is executed
again. This repeats until the condition becomes
false.
while(condition) {
// code to be
executed
}
int i = 0;
while(i < 5) {
cout << i << "n";
i++;
}
Condition: This is a Boolean expression that is
checked before each iteration of the loop. If the
condition is true, the loop continues; if it’s
false, the loop ends and control passes to the
next line of code after the loop.
Code to be executed: This is the code that is
run for each iteration of the loop, as long as the
condition is true.
A do-while loop in Turbo C++ is a
variant of the while loop. Unlike the
while loop, the do-while loop
checks the condition after
executing the statements within the
loop. This means that the do-while
loop will execute its statements at
least once, even if the condition is
false.
do {
// code to be
executed
} while(condition);
#include<iostream.h>
#include<conio.h>
main() {
clrscr();
int i = 1;
do {
cout << i << "n";
i++;
} while(i <= 5);
getch();
return 0;
}

More Related Content

PPT
Programs in C based on looping statements
PDF
Chapter 3
PPTX
Introduction& Overview-to-C++_programming.pptx
PPTX
Introduction to C++ programming language
PDF
Chapter 9 - Loops in C++
PDF
whileloop-161225171903.pdf
PPTX
Loops in c
PPT
While loop
Programs in C based on looping statements
Chapter 3
Introduction& Overview-to-C++_programming.pptx
Introduction to C++ programming language
Chapter 9 - Loops in C++
whileloop-161225171903.pdf
Loops in c
While loop

Similar to Introduction to programming in C++ : Loop Structure.pptx (20)

PPTX
Loops in c language
PPTX
Loops in c language
PDF
CS305PC_C++_UNIT 2.pdf jntuh third semester
PPTX
Lecture 5
DOC
Jumping statements
DOCX
itretion.docx
PPTX
Managing input and output operations & Decision making and branching and looping
DOCX
loops and iteration.docx
PPTX
What is loops? What is For loop?
PPTX
Loops in C.net.pptx
PPTX
Lec7 - Loops updated.pptx
PPTX
5.pptx fundamental programing one branch
PPT
Visula C# Programming Lecture 4
DOCX
Programming Fundamentals lecture 8
PPTX
C Programming Loop
PPTX
Flow Control (C#)
PPTX
C Programming Control Structures(if,if-else)
PDF
computing for engineering , data porgraming
PDF
Loop and while Loop
PPTX
Condition Stmt n Looping stmt.pptx
Loops in c language
Loops in c language
CS305PC_C++_UNIT 2.pdf jntuh third semester
Lecture 5
Jumping statements
itretion.docx
Managing input and output operations & Decision making and branching and looping
loops and iteration.docx
What is loops? What is For loop?
Loops in C.net.pptx
Lec7 - Loops updated.pptx
5.pptx fundamental programing one branch
Visula C# Programming Lecture 4
Programming Fundamentals lecture 8
C Programming Loop
Flow Control (C#)
C Programming Control Structures(if,if-else)
computing for engineering , data porgraming
Loop and while Loop
Condition Stmt n Looping stmt.pptx
Ad

Recently uploaded (20)

PPT
Teaching material agriculture food technology
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Cloud computing and distributed systems.
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Approach and Philosophy of On baking technology
PDF
cuic standard and advanced reporting.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Electronic commerce courselecture one. Pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Empathic Computing: Creating Shared Understanding
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Teaching material agriculture food technology
NewMind AI Weekly Chronicles - August'25 Week I
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Reach Out and Touch Someone: Haptics and Empathic Computing
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Cloud computing and distributed systems.
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
The AUB Centre for AI in Media Proposal.docx
Approach and Philosophy of On baking technology
cuic standard and advanced reporting.pdf
Unlocking AI with Model Context Protocol (MCP)
Dropbox Q2 2025 Financial Results & Investor Presentation
Spectral efficient network and resource selection model in 5G networks
Review of recent advances in non-invasive hemoglobin estimation
Electronic commerce courselecture one. Pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Network Security Unit 5.pdf for BCA BBA.
Empathic Computing: Creating Shared Understanding
Chapter 3 Spatial Domain Image Processing.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Ad

Introduction to programming in C++ : Loop Structure.pptx

  • 2. In Turbo C++, a for loop is a control flow statement that allows code to be executed repeatedly.
  • 4. Initialization: This is where you initialize your loop counter. This statement is executed only once. Condition: This is a boolean expression that the system checks before each loop iteration. If it’s true, the loop continues; if it’s false, the loop ends. Increment/Decrement: This statement is executed at the end of each loop iteration.
  • 5. #include<iostream.h> #include<conio.h> void main() { clrscr(); for(int i = 1; i <= 10; i++) { cout << i << "n"; } getch(); return 0; }
  • 6. A while loop in programming is a control flow statement that allows a certain piece of code to be executed repeatedly based on a given Boolean condition. The while loop can be thought of as a repeating if statement. The code inside the loop is executed, and then the Boolean condition is evaluated. If the condition is true, the code inside the loop is executed again. This repeats until the condition becomes false.
  • 7. while(condition) { // code to be executed }
  • 8. int i = 0; while(i < 5) { cout << i << "n"; i++; }
  • 9. Condition: This is a Boolean expression that is checked before each iteration of the loop. If the condition is true, the loop continues; if it’s false, the loop ends and control passes to the next line of code after the loop. Code to be executed: This is the code that is run for each iteration of the loop, as long as the condition is true.
  • 10. A do-while loop in Turbo C++ is a variant of the while loop. Unlike the while loop, the do-while loop checks the condition after executing the statements within the loop. This means that the do-while loop will execute its statements at least once, even if the condition is false.
  • 11. do { // code to be executed } while(condition);
  • 12. #include<iostream.h> #include<conio.h> main() { clrscr(); int i = 1; do { cout << i << "n"; i++; } while(i <= 5); getch(); return 0; }