0% found this document useful (0 votes)
6 views2 pages

Chapter 5 Control Structures Simplified

Uploaded by

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

Chapter 5 Control Structures Simplified

Uploaded by

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

Chapter 5: Control Structures (Simplified)

Control structures are the way we control the flow of a program. Normally, a program runs
step by step, top to bottom. But sometimes we need to make decisions or repeat actions.
That’s why control structures exist.

Types of Control Structures

1. Sequence Structure (Straight line path)


Instructions are carried out one after another in order. Nothing is skipped.

✅ Example in real life:


Making tea → Boil water → Add tea leaves → Add sugar → Serve.

✅ Example in VB:

Dim a As Integer, b As Integer


a=5
b = 10
MsgBox a + b

2. Selection Structure (Decision making / Branching)


Program makes a choice depending on a condition. Implemented using If, If…Else, or Select
Case.

✅ Example in real life:


If it’s raining → Take an umbrella
Else → Wear sunglasses

✅ Example in VB:

Dim age As Integer


age = 20

If age >= 18 Then


MsgBox "You are an adult"
Else
MsgBox "You are underage"
End If

3. Loop Structure (Repetition)


Used when we want to repeat actions. Implemented using For, While, or Do While.

✅ Example in real life:


Brushing teeth → Move brush left and right 10 times.
✅ Example in VB (For Loop):

Dim i As Integer
For i = 1 To 5
MsgBox "Hello"
Next i

Why Control Structures Matter


• They help in decision making.
• They make programs smarter (not just fixed steps).
• They allow repetition without writing the same code many times.

In Summary
• Sequence = Straight line (do steps one after another).
• Selection = Choose a path (If…Else, Select Case).
• Loop = Repeat actions (For, While, Do While).

You might also like