A unary operation is an operation that has only one input. For example in the expression -
is a unary operator. It acts on a single input: 50
.
Operator Description | C Symbol |
---|---|
Negation (flips the sign of a number) | - |
Increment (adds 1 to a number) | ++ |
Decrement (subtracts 1 from a number) | -- |
Logical NOT (inverts the logical value) | ! |
Bitwise NOT (flips the bits of a number) | ` |
Address-of (gets the memory address of a variable) | & |
Dereference (gets the value at a memory address) | * |
Sizeof (gets the size of a variable or data type in bytes) | sizeof |