C operators — match operator to its description List I (Operator) A. ?: (ternary) B. [ ] (subscript) C. % (percent) List II (Description) 1. Modulus (remainder) 2. Array expression / element access 3. Conditional (if-else in expression form)

Difficulty: Easy

Correct Answer: A-3, B-2, C-1

Explanation:


Introduction / Context:
Operator literacy is central to reading C code quickly and safely. This match tests three frequently used operators that influence control flow, indexing, and arithmetic results.


Given Data / Assumptions:

  • Standard ISO C semantics.
  • Integer operands for modulus.
  • Zero-based array indexing.


Concept / Approach:
The ternary operator implements an inline conditional; the subscript operator indexes arrays/pointers; and the percent sign performs remainder arithmetic on integers. We map each symbol to its canonical description from the C grammar and standard library usage.


Step-by-Step Solution:

A (?:) → conditional expression → 3.B ([ ]) → array element access / pointer arithmetic sugar → 2.C (%) → modulus (remainder) operator → 1.


Verification / Alternative check:
Compile small snippets: int x = cond ? a : b; selects between values; arr[i] is *(arr + i); 7 % 3 yields 1 in C.


Why Other Options Are Wrong:

  • Swapping array access and modulus descriptions would misrepresent syntax and behavior.
  • Placing “conditional” on [] or % is semantically incorrect.


Common Pitfalls:
Assuming % is a true mathematical modulus for negatives—C defines remainder with implementation-defined sign rules in older standards; modern C17 specifies truncation toward zero.


Final Answer:
A-3, B-2, C-1

More Questions from Matching Questions

Discussion & Comments

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