Control Structure
A control structure in programming is a set of rules that control the order in which
instructions are executed in a program.
It decides whether the program will:
Run step by step (sequence)
Make a choice (decision)
Repeat steps (looping)
Or skip/stop steps (jump)
👉 One-line easy definition:
Control structure = The way a program controls its flow of execution.
1. What is Control Structure?
A control structure tells the computer how the program should run step by step.
It controls the flow of instructions in a program.
Without control structures, a program would only run line by line without any decisions
or repetition.
👉 Simple Definition:
Control structure = Rules that control the flow of a program.
2. Types of Control Structures
(a) Sequential Structure
Steps run one after another.
Example:
print("Step 1")
print("Step 2")
print("Step 3")
👉 Output: Always Step 1 → Step 2 → Step 3
(b) Decision Structure (Selection)
Program chooses a path based on a condition.
Uses if, if-else, if-elif-else.
Example:
marks = 60
if marks >= 50:
print("Pass")
else:
print("Fail")
👉 If condition true → "Pass", otherwise → "Fail".
(c) Looping Structure (Repetition)
A task repeats multiple times.
Uses for, while.
Example:
for i in range(3):
print("Hello")
👉 "Hello" will print 3 times.
(d) Jump Structure
Changes the normal flow suddenly.
Uses break, continue, pass.
Example:
for i in range(5):
if i == 3:
break
print(i)
👉 Loop stops when i = 3.
3. What is the Flow of a Program?
Flow of a program means the order in which statements are executed.
It can be:
1. Sequential → Step by step
2. Decision → Choose one path
3. Looping → Repeat steps
👉 Example:
print("Start")
if 5 > 3:
print("Condition True")
print("End")
Flow: Start → Condition checked → Print result → End
What is a Control Structure?
In programming, a control structure is a block of code that decides the order in which
instructions are executed.
👉 In simple words:
A control structure controls the flow of a program — which statements run, when they run, and
how many times they run.
Types of Control Structures
1. Sequential Control Structure
Default flow: statements execute one after another in order.
Example:
print("Start")
print("Hello")
print("End")
2. Decision (Selection) Control Structure
Used when the program needs to make a choice.
Based on conditions (True/False).
Keywords: if, if-else, if-elif-else
Example:
age = 18
if age >= 18:
print("You can vote")
else:
print("You cannot vote")
3. Looping (Repetition) Control Structure
Used when a task needs to be repeated multiple times.
Keywords: for, while
Example:
for i in range(5):
print("Hello")
4. Jump Control Structure
Used to change the normal flow suddenly.
Keywords: break, continue, pass
Example:
for i in range(5):
if i == 3:
break # stops loop when i = 3
print(i)
✅ So in short:
Sequential → Step by step
Decision → Choose path
Looping → Repeat steps
Jump → Change flow suddenly
Would you like me to also draw a flowchart diagram showing how these control structures
look visually?
You said:
what is flow of a program
ChatGPT said:
Good question 👌 Let’s make it simple for you.
What is Flow of a Program?
The flow of a program means the order in which the instructions or statements of a
program are executed by the computer.
👉 In simple words:
It’s the path that a program follows when it runs — from start to end.
Types of Program Flow
1. Sequential Flow
o The program runs line by line in order.
o Example:
2. print("Step 1")
3. print("Step 2")
4. print("Step 3")
👉 Output will always be: Step 1 → Step 2 → Step 3
2. Conditional (Decision) Flow
o The program takes different paths depending on conditions.
o Example:
3. age = 20
4. if age >= 18:
5. print("You can vote")
6. else:
7. print("You cannot vote")
👉 Flow changes depending on the condition (age).
3. Looping (Repetition) Flow
o Some steps are repeated multiple times.
o Example:
4. for i in range(3):
5. print("Hello")
👉 Flow repeats the print statement 3 times.
4. Jump Flow
o Flow can skip, stop, or jump using statements like break, continue, return.
o Example:
5. for i in range(5):
6. if i == 3:
7. break # jumps out of loop
8. print(i)
✅ So, Flow of a Program = How the program moves from one step to another (in order, by
decision, by repetition, or by jumping).