論理型の変数A、Bの値に対して、次の条件文と同意なものはどれか。
ここで、ANDは論理積、ORは論理和、XORは排他的論理和、Trueは真、Falseは偽、=等号を表す。
if (A=True AND B=False) OR (A=False AND B=True) then …
ア | if ((A AND B)=True) then |
イ | if ((A AND B)=False) then |
ウ | if ((A OR B)=True) then |
エ | if ((A XOR B)=True) then |
答え エ
【解説】
“if (A=True AND B=False) OR (A=False AND B=True) then …”の
“A=True AND B=False”は、Aが真、Bが偽のとき、真
“A=False AND B=True”は、Aが偽、Bが真のとき、真
であり、これの論理和であるので、排他的論理和のことである。
【キーワード】
・論理演算