Page 56 - Digicode_AI_class_8
P. 56
We learnt about writing algorithms for a program and using conditional statements in a program.
Let us learn multiple conditions and looping in a program.
Multiple Conditions in a Program
Conditional statements are
used in a program to instruct the
Yes If (Condition) No
computer to make a decision.
Then to be checked Else
The result of the computer’s
decision for a condition will Statements to Statements to
be executed be executed
always be either a true or a
false. The program executes the statements written after ‘if’ when the condition is true. If it is false,
the statements written after ‘else’ will be executed.
But there might be situations when we need to check for multiple conditions in a program. For
example, look at these programs:
If (3>2) AND (3>4) If (3>2) OR (3>4)
Then Then
Write “Yes” Write “Yes”
Else Else
Write “No” Write “No”
No Yes
What did you notice?
Both the programs have two IF conditions joined together either through AND or OR. And the final
result depends on the combined result.
AND: results in YES only if both the conditions are true. If any condition is false, the result will
be false.
OR: results in YES if any one of the conditions is true. If both are false, the result will be false.
Now, write your answers for both.
1. 2.
If (you are a girl) AND (you are born in April) If (you are a girl) OR (you are born in April)
Then Then
Write “Both” Write “Any one”
Else Else
Write “None” Write “None”
54 DigiCode AI-VIII

