0% found this document useful (0 votes)
13 views7 pages

Program Control Presentation

The document outlines various program control structures that manage the flow of execution in programming, including for loops, switch statements, do...while loops, break, and continue statements. It explains the purpose and usage of each structure with examples in C. Additionally, it discusses logical operators that facilitate decision-making in conditions.

Uploaded by

Rida Zaniab
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views7 pages

Program Control Presentation

The document outlines various program control structures that manage the flow of execution in programming, including for loops, switch statements, do...while loops, break, and continue statements. It explains the purpose and usage of each structure with examples in C. Additionally, it discusses logical operators that facilitate decision-making in conditions.

Uploaded by

Rida Zaniab
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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";
}

You might also like