Unary operator
Updated: 03/05/2023 by Computer Hope
In computer programming, a unary operator is an operator that takes only one value for its operation.
An example in the C programming language is the increment operator (++), which increments a given value by 1. For instance, to increment the variable x by 1, you could express this as:
x++
We only needed one value (x) in this statement. Compare this to using the addition operator (+):
x + 1
This operation required two values (x and 1) and is an example of a binary operation.