Page 93 - TP_Play_V2.2_Class8
P. 93
Take Off Century #Critical Thinking
21 st
Skills
Write the output of the following statements:
1. if (today is Sunday) 2. if (a>90)
then then
display “Weekend” display “Excellent”
else else
display “No weekend” display “Try harder”
Assume that today is Sunday Assume that the value of a is 85.
We learnt about writing algorithms for a program and using conditional statements in a program. Let
us learn about 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. The to be checked
result of the computer’s decision Then Else
for a condition will always be a Statements to Statements to
boolean value i.e. either a true or a be executed be executed
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: It results in YES only if both the conditions are true. If any condition is false, the result will be false.
OR: It results in YES if even one of the conditions is true. If both are false, the result will be false.
#Algorithmic Intelligence 91

