0% found this document useful (0 votes)
131 views

Conditional Branching

The document discusses conditional branching in programming using if-then constructs and provides examples of algorithms and flowcharts that incorporate conditional logic. Students complete activities to practice writing pseudocode with if-then statements and constructing flowcharts representing conditional branching. The activities evaluate conditions such as stopping positions in a game, exam marks, and time to determine the appropriate output or next steps.

Uploaded by

api-546162315
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
131 views

Conditional Branching

The document discusses conditional branching in programming using if-then constructs and provides examples of algorithms and flowcharts that incorporate conditional logic. Students complete activities to practice writing pseudocode with if-then statements and constructing flowcharts representing conditional branching. The activities evaluate conditions such as stopping positions in a game, exam marks, and time to determine the appropriate output or next steps.

Uploaded by

api-546162315
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Conditional Branching:

If…Then Construct
Ms. Emamdee
Set Induction

Students volunteer to play a game of Snakes and Ladders:


https://www.crazygames.com/game/snakes-and-ladders
Moves in playing Snakes and Ladders

Roll dice
If stopped at Move up the ladder
the bottom of
a ladder

Move counter the number of


spaces rolled
If stopped at
the head of a Move down the snake
snake
Individual Activity: Game 1

• Students complete the following activity in a 3 minute time allotment


• https://www.liveworksheets.com/myworkbooks/preview.asp?workbookid=950814&clave=
vcm8oe41
Decision Construct

If ( evaluating condition ) Then


//Conditional instructions to be executed if the condition is TRUE
EndIf
Evaluating/Testing
condition

If (stop at the bottom of ladder) Then


move counter to the top of ladder
EndIf
Evaluating/Testing
condition

If (stop at the head of a snake) Then


move counter to the end of snake’s tail
EndIf
Write an algorithm in Read mark
pseudocode that will read If ( mark > = 50 ) Then
an exam mark. If the Write “Pass”
mark is greater than or EndIf
equal to 50, it will output
“Pass”.
Activity

• Padlet activity to construct algorithms with conditional branching in pseudocode.


Flowchart Representation
Flowchart symbols

Start/Stop Process Input/Output

Flow line Off-page connector

Decision
Start

Write an algorithm in Read time


pseudocode that will read
an exam mark. If the
mark is greater than or Yes Mark No
>= 50?
equal to 50, it will output
“Pass”.
Write “Pass”

Stop
Group Activity

• Construct a flowchart to represent the solution to the problem assigned.


Start

Read time

Write an algorithm in Read time


pseudocode that will read If (time = 12:00 ) Then
the time. If the time is Write “Lunch Time” Yes time = No
12:00?
12:00 it will output EndIf
“Lunch Time”.
Write “Lunch
time”

Stop

You might also like