What does the term "Increment/decrement operator" mean?

A type of operator which allows you to increase or decrease a particular variable by 1. Depending on the language, the result can be returned.

Although they vary in how they are written between languages, the increment / decrement operators are roughly as follows:

OperatorExampleDescription
++x++2 adds 1 to 2 and then returns 3Increases x by 1 and then returns x
x++2++ returns 2 then adds 1 to 2Returns x and then increases x by 1
–x–2 subtracts 1 from 2 and then returns 1Decreases x by 1 and then returns x
x–2– returns 2 then subtracts 1 from 2Returns x and then decreases x by 1

Leave a Reply

Thank you for choosing to leave a comment. Comments may be moderated.