Page 14 - Touchcode_C8_Flipbook
P. 14
When there are many logical operators of the same precedence, then the operator will be
examined from left to right.
Higher Precedence Logical Operator
not
and
Lower Precedence or
Consider the table:
A1 && A2 && A3 || A4 can be interpreted as ((A1 && A2) && A3) || A4
A1 || A2 && A3 can be interpreted as A1 || (A2 && A3)
!A1 && A2 || A3 can be interpreted as ((!A1) && A2) || A3
A1 && A2 || A3 && A4 can be interpreted as (A1 && A2) || (A3 && A4)
In the above table A1, A2, A3 and A4 stand for the relational expressions, in which the mix
of ‘&&’, ‘||’ and ‘!’ operators are used. The expression in the first column can be interpreted
by parentheses as shown in the third column.
So, parentheses are used to group operands together rather than relying on a logical
operator precedence rules.
Coding fact
Frank Gilbreth invented the concept of flowchart in 1921 as an organised
method to represent the process flow.
Subject Enrichment
Coding Task 02
To create a program in MakeCode to check if a number is even or odd.
In this task, you will create a program which checks if the entered number is divisible by
2 or not, if the entered number is divisible by 2, then the message will be displayed as
‘Number is even’, else the message will be displayed as ‘Number is odd’.
12 Touchcode-VIII

