Program Control Structures
• Program control structures help control the
flow of execution.
• Common structures: for, switch, do…while,
break, continue.
• Logical Operators allow decision making.
For Loop – Definition
• A for loop repeats a block of code a specific
number of times.
• Useful when number of iterations is known.
Example (C):
for(int i = 1; i <= 5; i++) {
print(“%d”, i)
}
Switch Statement – Definition
• • Switch is used when you have multiple
conditions based on a single variable.
• • Makes code cleaner than multiple if-else.
• Example:
• switch(day) {
• case 1: cout << "Monday"; break;
• case 2: cout << "Tuesday"; break;
• default: cout << "Invalid";
• }
Do…While Loop – Definition
• do…while executes code at least once before
checking condition.
• Useful when first execution must happen.
Example:
int i = 1;
do {
cout << i;
i++;
} while(i <= 5);
Break Statement
• break stops the loop immediately.
• Used to exit loops or switch.
Example:
for(int i = 1; i <= 10; i++) {
if(i == 5) break;
cout << i;
}
Continue Statement
• continue skips current iteration and moves to
next.
Example:
for(int i = 1; i <= 5; i++) {
if(i == 3) continue;
cout << i;
}
Logical Operators
• Used in conditions to make decisions.
• AND (&&), OR (||), NOT (!)
Example:
if(age >= 18 && citizen == true) {
cout << "Eligible";
} else {
cout << "Not Eligible";
}