Concept check: In C, are the bitwise operators & and | unary operators or binary (dyadic) operators?

Difficulty: Easy

Correct Answer: False

Explanation:


Introduction / Context:
This conceptual question verifies operator arity in C. Understanding whether an operator is unary (one operand) or binary (two operands) is essential for parsing and writing expressions correctly.



Given Data / Assumptions:

  • Operators under consideration: & and |.
  • We are discussing bitwise operators, not logical operators.


Concept / Approach:
In C, bitwise AND (&) and bitwise OR (|) each combine two operands bit-by-bit, producing a result of the same integer type after usual conversions. Therefore, they are binary (dyadic) operators. Their unary counterparts do not exist; the only unary bitwise operator is ~ (bitwise NOT).



Step-by-Step Solution:
Examine usage: a & b (two operands) and a | b (two operands).Contrast with unary operators such as ~a, +a, -a, ++a.Conclusion: & and | are binary.



Verification / Alternative check:
Refer to C operator precedence tables: & and | appear in binary operator groups (bitwise AND, bitwise OR), distinct from unary operator section.



Why Other Options Are Wrong:
True: incorrectly asserts that & and | are unary.Other distractors are irrelevant to the unary/binary distinction.



Common Pitfalls:
Confusing bitwise with logical operators (&&, ||), which are also binary, or mixing & (bitwise) with address-of operator & (unary) in a different context.



Final Answer:
False

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion