Cprogramming-c-logical-operators
提供:Dev Guides
Cの論理演算子
次の表は、C言語でサポートされているすべての論理演算子を示しています。 変数 A が1を保持し、変数 B が0を保持すると仮定します-
Operator | Description | Example |
---|---|---|
&& | Called Logical AND operator. If both the operands are non-zero, then the condition becomes true. | (A && B) is false. |
Called Logical OR Operator. If any of the two operands is non-zero, then the condition becomes true. | (A | |
B) is true. | ! | Called Logical NOT Operator. It is used to reverse the logical state of its operand. If a condition is true, then Logical NOT operator will make it false. |
例
Cで利用可能なすべての論理演算子を理解するために、次の例を試してください-
上記のプログラムをコンパイルして実行すると、次の結果が生成されます-