C/C++ operators — match each operator symbol (List I) with its correct description (List II). List I (Operator) A. != B. == C. << D. >> List II (Description) 1. Left shift (bitwise) 2. Right shift (bitwise) 3. Equal to (relational) 4. Not equal to (relational)
-
AA-1, B-2, C-3, D-4
-
BA-2, B-3, C-4, D-1
-
CA-4, B-1, C-3, D-2
-
DA-4, B-3, C-1, D-2
Answer
Correct Answer: A-4, B-3, C-1, D-2
Explanation
Introduction / Context:Programming interview and exam questions often test whether students can quickly recognize operator semantics. This item pairs common relational and bitwise shift operators with their meanings in C/C++ and many C-like languages.
Given Data / Assumptions:
- Operators appear exactly as typed in source code.
- We distinguish relational operators (comparisons) from bitwise shifts.
- No precedence or side-effect subtleties are tested here—only meanings.
Concept / Approach:
Identify the category first (relational vs. bitwise). Then map symbols to familiar English descriptions: != means “not equal to”; == means “equal to”; << and >> mean left and right bit shifts, respectively.
Step-by-Step Solution:
A: != → Not equal to → 4.B: == → Equal to → 3.C: << → Left shift → 1.D: >> → Right shift → 2.Verification / Alternative check:
Small test: 5 != 6 evaluates true; 5 == 6 evaluates false. For shifts, 1 << 3 equals 8 and 8 >> 2 equals 2, confirming the meanings.
Why Other Options Are Wrong:
- Swapping the relational meanings (== with “not equal” or != with “equal”) inverts logic.
- Interchanging left and right shifts reverses the direction of bit movement and the power-of-two scaling.
Common Pitfalls:
Confusing bitwise shifts with stream insertion/extraction operators in C++ iostreams; they reuse the symbols but are overloaded as functions, not fundamental shifts.
Final Answer:
A-4, B-3, C-1, D-2