Page 98 - TP-Play_V-2.0_Book-8
P. 98
ALGORITHMIC INTELLIGENCE
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 Yes If (Condition) No
the computer to make a Then to be checked Else
decision. The result of the Statements to Statements to
computer’s decision for a be executed be executed
Computational Thinking will be executed. If (3>2) AND (3>4) If (3>2) OR (3>4)
condition will 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’
But there might be situations when we need to check for multiple conditions in a program.
For example, look at these programs:
Then
Else Write “Yes” Then Write “Yes”
Else
Write “No” Write “No”
No Yes
What did you notice?
Both the programs have two IF conditions together joined either through AND or OR.
And the final result depends on the combination 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.
98 Play (Ver. 2.0)-VIII

