Page 35 - IT_V5.0_Class6
P. 35
_____________________________________________________________________________________________________
_____________________________________________________________________________________________________
_____________________________________________________________________________________________________
Problem 4: Write an algorithm to convert hours to minutes.
_____________________________________________________________________________________________________
_____________________________________________________________________________________________________
_____________________________________________________________________________________________________
_____________________________________________________________________________________________________
_____________________________________________________________________________________________________
_____________________________________________________________________________________________________
CONTROL STRUCTURES IN AN ALGORITHM
When we write an algorithm, we often need to control the flow of how the steps happen. This
is done using control structures. These are like "rules" that tell the algorithm what to do next
based on certain conditions. There are three main control structures: sequential, selection, and
repetition.
Sequential
This is the simplest form of an algorithm where the steps of the algorithm are followed one
after another, in order, just like reading a book from the first page to the last without skipping
anything. The algorithms you have written till now are examples of sequential structure.
Selection
This is a control structure in an algorithm where you make a choice. It’s like asking a question
and then deciding what to do next based on the answer. The algorithm will follow one path if
a condition is true and a different path if the condition is false. In simple terms, it helps the
algorithm make decisions. For example, checking if you need to charge your phone:
If the phone battery is below 20%, charge the phone.
Else, charge the phone.
The algorithm will be:
Step 1: Start
Step 2: Check the phone battery.
Step 3: IF the battery is below 20% THEN
Charge the phone.
Step 4: ELSE:
Continue using the phone.
Step 5: Stop
Algorithm and Flowchart 33

