☰ Contents · Computing

The branching algorithm: “if” and the condition

Lessons 25–27 · 3 lessons · F.M. Zakirova, M.R. Zakirova. Informatics and Information Technology Grade 2. Novda Edutainment, 2024
26

Flowchart of a branching algorithm

Textbook: pp. 69–71
GoalRead the flowchart of a branching algorithm: the condition in a diamond and the “yes” / “no” branches.
New words
diamond · rombyes · hano · yo‘qbranch · tarmoq
Explanation

In a flowchart a condition is written in a diamond. The diamond holds a question that can be answered only “yes” or “no”. Two arrows leave the diamond: one for “yes”, one for “no”. Only one branch is carried out at a time: you cannot go both right and left. A condition block is a diamond, a command block is a rectangle.

Worked examples
(Start) → ‹Is it raining?› → yes: [put on boots]; no: [put on shoes] → [go outside] → (End).
Two arrows leave a diamond, but only one leaves a rectangle.
Class activity

“Floor flowchart”: draw a diamond on the floor with two paths (“yes” and “no”). A child answers the question and walks along the right path: “Is it raining today?”

Practice
1
It is not raining. By the flowchart above, which footwear is worn?
2
How many arrows leave a diamond?
3
Can we do both branches at the same time?