You are on page 1of 2

|

|Om Shr
iSai|
|

LOGI CALOPERATORS
Inor dert ologicallyrepr esentacondi ti
oni na“ C”
program, “C”Languagesuppor tstheuseofl ogical
operators.Thr eet ypesofl ogicaloperat or
sar esuppor tedin
“C”Language, theyar e
1)ANDOper ator(&&)
2)OROper ator(| |)
3)NOTOper ator(!)
TheANDandt heORoper atorareusedt ocombi ne
mul ti
plecondi ti
onsi nasi ngleIfstatement ,wher eas
theNOToper atori susedt oreverset hest atusofa
condi ti
on.
Ifacondi ti
oni struei tisr eplacedby1andi fa
conditi
oni sfalsei tisrepl acedby0.Si mi l
arl
y ,any t
hingnon
zeroisalway sconsi der edast ruewher easzer oisal way s
consideredasf alse.
1)ANDOper ator(&&)
Whenmul t
iplecondi tionsar ecombi nedusi ngt heAND
Operator,ifallthespeci fi
edcondi ti
onsar etrue, onlythen
thetotalcondi ti
oni sconsi deredt obet rue.i.
e.ev eni fa
singl
econdi tionf ail
st het otalcondi ti
onal sofails.

&& 0 1
0 0 0
1 0 1

2)OROper ator(||)
Whenmul t
ipl
econdi t
ionsarecombinedusingtheOR
Operator,
evenifasingleconditi
onistr
ue,thetotal
conditi
onisconsideredast r
ue.i.
e.Onl
yifallt
hecondit
ions
fai
lthenthetotalcondit
ionfail
s.

|
| 0 1
0 0 1
1 1 1

3)NOTOper ator(!)
TheNOTOper atorisplacedinfrontofacondi
ti
onin
anifelsestatement .NOTr eversesthestat
usofthe
condit
ion.i
.e.Ift
hecondi t
ionistrue,NOTmakesi tf
alse.I
f
theconditi
oni sf
alse, NOTmakesi ttr
ue.
!

0 1
1 0

You might also like