Computer Programming (COPROG) Practice Test

Access More Questions
What are unary operators?
Correct Answer:
Operators that need only one operand
Explanation:
Unary operators are the ones that act on a single value. They take one operand and produce a result. Examples include the unary minus that changes the sign of a number (-x), the logical NOT that inverts a boolean value (!x), and even unary plus or bitwise NOT (~x). The key idea is how many inputs the operator needs: one input value. This sits in contrast to binary operators, which require two operands (like a + b), and to ternary expressions, which involve three operands. The other choices describe what the operator does in terms of producing values or having zero operands, rather than describing how many inputs the operator requires.

Access more questions from this quiz

Continue to Computer Programming (COPROG) Practice Test for more practice questions and the full quiz experience.

Access More Questions