Control Structures of
Programming
Introduction to Programming Concepts by Amali Gunasinghe MSc,
BSc(Hons) in Information Technology(SLIIT)
by Rutvika Ghadiyali
Learning Objectives
Understand Control Identify Types Implementation
Structures
Differentiate between Learn to implement and use
Grasp the concept and sequential, conditional, control structures in programs.
importance in programming. iterative, and branching
structures.
What are Control Structures?
Control structures are fundamental programming Types of Control Structures:
concepts that control the flow of execution in a
• Sequential Control
program.
They enable programs to make decisions, repeat tasks, • Conditional Control (Selection)
or execute code conditionally.
• Iterative Control (Loops)
• Branching Control
Sequential Control
Brush your teeth
Have breakfast
Pack your bag
Go to school
Instructions are executed one after another in a linear order, like a
morning routine.
Conditional Control (Selection)
If Statement
1 Executes code if condition is true
If-Else Statement
2 Provides alternative path if condition is false
Else-If Ladder
3 Checks multiple conditions in sequence
Conditional control allows programs to make decisions based on specific conditions.
Conditional Examples
If-Else Example Else-If Example Nested Conditions
age = 18 score = 85 if weather == "sunny":
if age >= 18: if score >= 90: if temperature > 25:
print("You can vote") print("Grade: A") print("Go swimming")
else: elif score >= 80: else:
print("Too young to print("Grade: B") print("Go hiking")
vote") else:
print("Grade: C")
Iterative Control (Loops)
For Loop While Loop
Repeats a known number of times. Repeats as long as a condition is true.
for i in range(5): number = 1
print("Practice makes perfect") while number <= 5:
print(number)
number += 1
Branching Control
Break Statement
Exits the loop immediately when a condition is met.
Continue Statement
Skips current iteration and moves to the next one.
Example
for i in range(10):
if i == 5:
break
print(i)
Summary
Sequential Conditional
Linear execution of instructions Decision-making based on conditions
Branching Iterative
Controlling flow within loops Repeating code multiple times
Practice using different control structures in simple programs to understand how they help in problem-solving.
Thank You
Contact Information
Email: amali.gunasinghe5@gmail.com
Questions?
Feel free to ask about any control structures concepts!
References
Kernighan & Ritchie, Kochan, Sipser, GeeksforGeeks,
TutorialsPoint