Page 268 - AI Ver 1.0 Class 9
P. 268
4. Coding and Implementation: This is the last step where every instruction of an algorithm is converted into
a computer understandable instruction by using the syntax and semantic of a specific computer language.
Control Structures
Control structures are a set of instructions that controls the flow of instructions in a program. It is a programming tool
that determines the order of execution of the statements in any programming language. There are three different
types of control structures Sequential flow, Selection flow and Repetition flow. Let us learn about these in detail.
Sequential Flow
In sequential flow, the statements are placed one after the other and the flow of execution occurs starting from
line1, line2 and so on with a top-down approach. It is the default flow followed in any programming language.
For example, the steps for calculating percentage of any student are:
1. Input marks of English, Hindi and Math
2. Total the marks
3. Calculate the percentage
4. Display the percentage
Selection Flow
Selection flow is also known as branching control as the flow of control branches based on a condition. A
condition evaluates to either TRUE or FALSE. In the case of TRUE, the flow of control follows the set of instructions
written for True. In case it is FALSE, then it follows the other route. For example, if we consider the above example
where we have a condition-award to be given if the percentage is more than 90 only.
1. Input marks of English, Hindi and Math
2. Total the marks
3. Calculate the percentage
4. Display the percentage
5. If percentage is more than 90 then
Display "Award given"
Otherwise
Display "No award"
Repetition Flow
Repetition flow is also known as a loop as it repeats a set of instructions a number of times based on a condition.
For example, if we wish to repeat the above steps of calculating percentage for 10 students then we follow the
concept of repetition.
1. Repeat for 10 people
• Input marks of English Hindi and Math
• Total the marks
• Calculate the percentage
• Display the percentage
• If percentage is more than 90 then
266 Touchpad Artificial Intelligence-IX

