Page 46 - IT_V5.0_Class8
P. 46
CONTROL STRUCTURES IN AN ALGORITHM
Control structure is defined as an order of execution of a statement in an algorithm. There are
three types of control structures: sequential, selection, and repetition. Let us explore them in
detail.
Sequential
This is the simplest form of control structure, where instructions are executed in a sequential
order, one after the other. For example, steps for calculating the percentage of any student:
1. Input marks for English, Hindi, and Maths.
2. Total the marks.
3. Calculate the percentage.
4. Display the percentage.
Let us write some algorithms based on sequential control structure.
Algorithm 3: Write an algorithm for adding two numbers and displaying the result.
Step 1: Start
Step 2: Input num1 and num2.
Step 3: Calculate Sum = num1 + num2.
Step 4: Display sum.
Step 5: Stop
Algorithm 4: Write an algorithm to calculate the area of the circle and display it.
Step 1: Start
Step 2: Input radius.
Step 3: Calculate area = 3.14 * radius * radius.
Step 4: Display area.
Step 5: Stop
Algorithm 5: Write an algorithm to input the temperature in Fahrenheit and convert it into
Celsius and display it.
Step 1: Start
Step 2: Input temp in Fahrenheit.
Step 3: Convert temp to Celsius = (temp - 32) * 5 / 9.
Step 4: Display Celsius.
Step 5: Stop
Selection
This structure allows the algorithm to make a decision based on a condition. If the condition is
true, a certain block of instructions is executed. If the condition is false, an alternative block of
instructions will be executed. For example, if we consider the above example where we have a
condition: Award to be given if the percentage is more than 90.
1. Input marks for English, Hindi, and Maths.
2. Total the marks.
44 Information Technology (V5.0)-VIII

