Junior — Middle
What is the function of the postfix negation operator in programming languages?
sobes.tech AI
Answer from AI
The postfix decrement operator (usually x-- in languages like Java, C, C++) decreases the value of the variable by 1 but returns its value before the decrement.
Example:
int x = 5;
int y = x--;
// After execution:
// y == 5 (value before decrement)
// x == 4 (value after decrement)
This differs from the prefix operator --x, which first decreases the value and then returns it.