Bismillah hiir Rehman nir Raheem-----------------------------Assalat o Wasalam o Alika Ya RasoolALLAH 165
i
4.1 Relational Operators
us uf
The == operator determines whether the operand on its left is equal to the operand on its right. If both operands have the same value, the expression is true. Assuming thar a is 4,
the follow ing expression is trlle: a --
4
But [he following is false: 2
WA R N I NG! Notice the equality operator is twO = symbols together. Don't confuse this operatOr with the assignmem ope rator, which is one .. symbol. The -- operator determines
whether a variable is equal to another val ue, bur the .. ope rator assigns the value on the operator's right to the va riable on its left. T here will be more about this later in the cbapter.
az
CD
::=
Yo
a
Ri
A coup le of the relational operators actua ll y test for tWO relationships. The >= operator dete rmines whether the operand on its left is greate r than or equa l to the ope rand on the right. Assuming tha t a is 4, b is 6, and c is 4, both of the fo llowing expressions arc true :
Bur the following is false:
ss
a >- 5
an
b >= a a >- c
a <=
C
b <= 10
Ha
The <- operator determ ines whether the operand on its left is less than or equa l to the o perand on its righ t. Once agai n, assuming tbar a is 4, b is 6, and c is 4, both of the fol lowing expressions arc true:
Bur the following is fa lse:
ad
b <= a
m
The last re lati onal operatO r is 1=, which is [he not-eq ual operator. It det ermines wh eth er the o perand on its left is not equa l ro the operand on its right, which is the opposite of the =- operator. As before, assum ing a is 4 , b is 6, a nd c is 4, both of the fo ll owing expresSIons are rrue :
m
a 1"" b b !: c
uh a
T hese expressions are true because a is Il o t equal to band b is not equal to c. But the fol lowing expression is fa lse because a is equal to c: a
! ::
c
M
Table 4 -3 shows other re lationa l exp ressions and their true or false values.
To Read Online & Download: WWW.ISSUU.COM/SHEIKHUHASSAN